package com.ymttest.business.service;

import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.ymatou.iapi.productmanager.parameter.*;
import com.ymatou.iapi.productmanager.parameter.product.*;
import com.ymatou.iapi.productmanager.parameter.productCheckStatus.CheckStatusDto;
import com.ymatou.iapi.productmanager.parameter.productCheckStatus.UpdateProductCheckStatusRequest;
import com.ymatou.iapi.productmanager.service.*;
import com.ymatou.iapi.productmongosync.service.EsCall;
import com.ymatou.iapi.productquery.parameter.GetProductListByProductIdListBean;
import com.ymatou.iapi.productquery.parameter.ProductDetail.ProductInDetailBean;
import com.ymatou.iapi.productquery.service.GetProductInfoByProductIdCall;
import com.ymatou.iapi.productquery.service.GetProductListByProductIdListCall;
import com.ymatou.iapi.productsync.service.MongocrudCallOld;
import com.ymatou.iapi.selleractivity.service.ApplyActivityCall;
import com.ymt.core.tool.FormatUtil;
import com.ymt.core.tool.Logger;
import com.ymttest.database.annotation.SqlMapperFactory;
import com.ymttest.database.annotation.product.IntergratedProductMapper;
import com.ymttest.database.model.*;
import com.ymttest.database.mongo.UserAnalysisMongoWapper;
import com.ymttest.database.mongo.YmtMongoDriverFactroy;
import com.ymttest.database.mongo.jproduct.ActivityProductsWapper;
import com.ymttest.database.mongo.jproduct.ProductTimeStampWapper;
import com.ymttest.database.sqlwapper.*;
import com.ymttest.utils.*;
import com.ymttest.utils.constant.JsonBeanFile;
import org.apache.http.client.ClientProtocolException;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.io.IOException;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;

public class ProductManagerCallServiceV2 {
	public final static String DefAddSellerProductPath = "com.ymatou.iapi.productmanager/AddSellerProductCall/addsellerproductcalltpl.json";
	private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
	// 商品价格 默认固定
	public static String price = "10";
	// 日志
	private static String logfile = "stgcreateproduct.log";
	// 活动id 固定 activityId 7887
	private static String activityId = "7887";
	private static String adminuser = "autotest";
	private static String adminpwd = "1234qwer";
	static {
		if (EnvSetup.getEnv().toLowerCase().equals("sit1")) {
			// sit数据
			activityId = "27037";
			adminuser = "autotest";
			adminpwd = "1234qwer";
		}
	}

	/**
	 * mongo 和es同步
	 * 
	 * @param activityId
	 * @param productId
	 * @param actionType
	 */
	public static void callMgoAndEs(int activityId, String productId, String actionType) {
		new MongocrudCallOld().callAndGetReturnData(activityId, productId, actionType);
		new EsCall().callAndGetReturnData(activityId, productId, actionType);
	}

	/**
	 * 搜索同步,用于manage站点的搜索功能前置
	 * 
	 * @param activityId
	 * @param productId
	 * @param actionType
	 */
	public static void esSync(int activityId, String productId, String actionType) {
		new EsCall().callAndGetReturnData(activityId, productId, actionType);
	}

	/**
	 * 总线 更新商品的审核状态 （强制、恢复下架） - UpdateProductCheckStatus
	 * @param sellerId
	 * @param productId
	 * @param checkStatus
	 * @param operator
	 * @throws IOException
	 */
	public static void UpdateProductCheckStatus(int sellerId,String productId,int checkStatus,String operator) throws IOException {
		List<CheckStatusDto> list = new ArrayList<CheckStatusDto>();
		CheckStatusDto checkStatusDto = new CheckStatusDto();
		checkStatusDto.setSellerId(sellerId);
		checkStatusDto.setProductId(productId);
		list.add(checkStatusDto);
		UpdateProductCheckStatusRequest updateProductCheckStatusRequest = new UpdateProductCheckStatusRequest();
		updateProductCheckStatusRequest.setCheckStatus(checkStatus);
		updateProductCheckStatusRequest.setOperator(operator);
		updateProductCheckStatusRequest.setProductList(list);
		UpdateProductCheckStatusCall updateProductCheckStatusCall = new UpdateProductCheckStatusCall();
		updateProductCheckStatusCall.setData(updateProductCheckStatusRequest);
		updateProductCheckStatusCall.callService();
	}

	/**
	 * 批量下架商品
	 * @param productIds
	 * @param sellerId
	 * @return
	 * @throws Exception
	 */
	public static JsonObject batchSetProductOffSale(List<String> productIds, Integer sellerId) throws Exception {
		BatchSetProductOffSaleCall BatchSetProductOffSaleCall = new BatchSetProductOffSaleCall();
		BatchSetProductSaleBean BatchSetProductOffSaleBean = new BatchSetProductSaleBean();
		BatchSetProductOffSaleBean.setUserId(sellerId);
		BatchSetProductOffSaleBean.setProductIds(productIds);
		BatchSetProductOffSaleCall.setData(false, BatchSetProductOffSaleBean);
		BatchSetProductOffSaleCall.callService();
		return BatchSetProductOffSaleCall.getJsonObject();
	}

	/**
	 * 发布微店商品
	 * @throws IOException 
	 * @throws ClientProtocolException 
	 */
	public static String addmicroproduct(Integer sellerId) throws ClientProtocolException, IOException{
		AddSellerProductRequest addProdReq =ProductManagerCallServiceV2.initAddSellerProductRequest(sellerId);
		WeChatProductModel weChatProductModel = new WeChatProductModel();
		weChatProductModel.setSellerId(sellerId);
		weChatProductModel.setProductName(addProdReq.getProduct().getProductName());
		weChatProductModel.setSecondCategoryId(addProdReq.getProduct().getSecondCategoryId());
		weChatProductModel.setCatalogStatus(addProdReq.getProduct().getCatalogStatus());
		weChatProductModel.setOnSaleType(-1);
		
		WeChatCatalogDto weChatCatalogDto1 = new WeChatCatalogDto();
		weChatCatalogDto1.setCatalogName(addProdReq.getProduct().getCatalogList().get(0).getPropertyList().get(0).getPropertyName());
		weChatCatalogDto1.setPicUrl(addProdReq.getProduct().getCatalogList().get(0).getPropertyList().get(0).getPropertyUrl());
		weChatCatalogDto1.setPrice(addProdReq.getProduct().getCatalogList().get(0).getPrice());
		weChatCatalogDto1.setStock(addProdReq.getProduct().getCatalogList().get(0).getStock());
		
		WeChatCatalogDto weChatCatalogDto2 = new WeChatCatalogDto();
		//weChatCatalogDto2.setCatalogId(cids.get(1).getsCatalogId());
		weChatCatalogDto2.setCatalogName(addProdReq.getProduct().getCatalogList().get(1).getPropertyList().get(0).getPropertyName());
		weChatCatalogDto2.setPicUrl(addProdReq.getProduct().getCatalogList().get(0).getPropertyList().get(0).getPropertyUrl());
		weChatCatalogDto2.setPrice(addProdReq.getProduct().getCatalogList().get(1).getPrice());
		weChatCatalogDto2.setStock(addProdReq.getProduct().getCatalogList().get(1).getStock());
		
		
		weChatProductModel.setCatalogList(Arrays.asList(weChatCatalogDto1,weChatCatalogDto2));
		ProductDescSaveModel productDescSaveModel = new ProductDescSaveModel();
		productDescSaveModel.setDescription(addProdReq.getProduct().getDescModel().getDescription());
		productDescSaveModel.setDescPicList(addProdReq.getProduct().getProductPicList());
		weChatProductModel.setProductDescModel(productDescSaveModel);
		weChatProductModel.setPicUrls(addProdReq.getProduct().getProductPicList());
		
		AddMicroProductBean addmicroproductBean = new AddMicroProductBean();
		AddMicroProductCall addmicroproductCall = new AddMicroProductCall();
		addmicroproductBean.setProduct(weChatProductModel);
		addmicroproductBean.setProductSite(addProdReq.getProductSite());
		addmicroproductBean.setReleaseProduct(false);
		addmicroproductCall.setData(addmicroproductBean);
		addmicroproductCall.callService();
		return addmicroproductCall.getJsonObject().get("Data").getAsJsonObject().get("ProductId").getAsString();
	}
	/**
	 * 上架商品
	 * 
	 * @param productIds
	 * @param sellerId
	 * @return
	 * @throws Exception
	 */
	public static JsonObject batchSetProductOnSale(List<String> productIds, Integer sellerId) throws Exception {
		BatchSetProductOnSaleCall BatchSetProductOnSaleCall = new BatchSetProductOnSaleCall();
		BatchSetProductSaleBean BatchSetProductOnSaleBean = new BatchSetProductSaleBean();
		BatchSetProductOnSaleBean.setUserId(sellerId);
		BatchSetProductOnSaleBean.setProductIds(productIds);
		
		BatchSetProductOnSaleCall.setData(false, BatchSetProductOnSaleBean);
		BatchSetProductOnSaleCall.callService();
		return BatchSetProductOnSaleCall.getJsonObject();
	}

	/**
	 * 按type查询商品 第一页 50条
	 * 
	 * @param sellerid
	 * @param tabtype
	 *            //销售中 OnSale(0), //待上架 OnNotSale(4), //售罄 SaleOut(6), //直播中的商品
	 *            InLive(7), //All All(-1);
	 * @return
	 * @throws IOException
	 * @throws ClientProtocolException
	 */
	public static List<String> getProducts(Integer sellerid, Integer tabtype) throws ClientProtocolException, IOException {
		QuerySellerProductBean querySellerProductBean = new QuerySellerProductBean();
		querySellerProductBean.setSellerId(sellerid);
		querySellerProductBean.setPageIndex(1);
		querySellerProductBean.setPageSize(50);
		QuerySellerProductListCall querySellerProductListCall = new QuerySellerProductListCall();
		querySellerProductBean.setTabType(tabtype);
		querySellerProductListCall.setData(false, querySellerProductBean);
		querySellerProductListCall.callService();
		List<String> plist = new ArrayList<>();
		if (!querySellerProductListCall.getJsonObject().get("Data").isJsonNull()) {
			JsonArray list = querySellerProductListCall.getJsonObject().get("Data").getAsJsonObject().get("ProductList").getAsJsonArray();
			list.forEach(jprod -> {
				plist.add(jprod.getAsJsonObject().get("ProductId").getAsString());
			});
		}
		return plist;
	}

	/**
	 * 获取商品列表
	 * 
	 * @param sellerid
	 * @param tabtype
	 * @param pageindex
	 * @param pagesize
	 * @return
	 * @throws ClientProtocolException
	 * @throws IOException
	 */
	public static List<String> getProducts(Integer sellerid, Integer tabtype, Integer pageindex, Integer pagesize) throws ClientProtocolException, IOException {
		QuerySellerProductBean querySellerProductBean = new QuerySellerProductBean();
		querySellerProductBean.setSellerId(sellerid);
		querySellerProductBean.setPageIndex(pageindex);
		querySellerProductBean.setPageSize(pagesize);
		QuerySellerProductListCall querySellerProductListCall = new QuerySellerProductListCall();
		querySellerProductBean.setTabType(tabtype);
		querySellerProductListCall.setData(querySellerProductBean);
		querySellerProductListCall.callService();
		List<String> plist = new ArrayList<>();
		if (!querySellerProductListCall.getJsonObject().get("Data").isJsonNull()) {
			JsonArray list = querySellerProductListCall.getJsonObject().get("Data").getAsJsonObject().get("ProductList").getAsJsonArray();
			list.forEach(jprod -> {
				plist.add(jprod.getAsJsonObject().get("ProductId").getAsString());
			});
		}
		return plist;
	}

	/**
	 * 设置商品的psp状态
	 * @throws IOException 
	 * @throws ClientProtocolException 
	 */
	public static void SetPspStatus(boolean IsPassViolate,boolean IsRemovePsp,Integer SellerId,String ProductId) throws ClientProtocolException, IOException{
		SetPspStatusBean setPspStatusBean = new SetPspStatusBean();
		setPspStatusBean.setIsPassViolate(IsPassViolate);
		setPspStatusBean.setIsRemovePsp(IsRemovePsp);
		setPspStatusBean.setProductId(ProductId);
		setPspStatusBean.setSellerId(SellerId);
		SetPspStatusCall setPspStatusCall = new SetPspStatusCall();
		setPspStatusCall.setData(setPspStatusBean);
		setPspStatusCall.callService();
	}
	
	
	/**
	 * 获取全部在售商品
	 * 
	 * @param sellerid
	 * @return
	 * @throws Exception
	 */
	public static List<String> getAllOnSaleProducts(Integer sellerid) throws Exception {
		boolean hasNext = true;
		List<String> alllist = new ArrayList<>();
		int index = 0;
		while (hasNext) {
			List<String> list = ProductManagerCallServiceV2.getProducts(sellerid, 0, index, 50);
			if (list.size() < 100) {
				hasNext = false;
			}
			index++;
			alllist.addAll(list);
		}
		return alllist;
	}

	/**
	 * 获取商品文描详情
	 * @return
	 * @throws IOException 
	 * @throws ClientProtocolException 
	 * @throws JSONException 
	 */
	public static JSONObject getNewProductDescriptionInfo(Integer userId,String productId) throws ClientProtocolException, IOException, JSONException{
		GetNewProductDescriptionInfoCall getNewProductDescriptionInfoCall = new GetNewProductDescriptionInfoCall();
		GetNewProductDescriptionInfoBean getNewProductDescriptionInfoBean = new GetNewProductDescriptionInfoBean();
		getNewProductDescriptionInfoBean.setproductId(productId);
		getNewProductDescriptionInfoBean.setuserId(userId);
		getNewProductDescriptionInfoCall.setData(getNewProductDescriptionInfoBean);
		getNewProductDescriptionInfoCall.callService();
		JSONObject jsonObject = new JSONObject(getNewProductDescriptionInfoCall.getReturnData()).getJSONObject("Data").getJSONObject("ProductDescriptionInfo");
		return jsonObject;
	}
	/**
	 * 批量更新商品的活动库存为0 -mssql Ymt_ProductActivityStock
	 * @deprecated
	 * @param productids
	 */
	public static void updateActivityStock0(List<String> productids) {
		YmtProductActivityStockWapper pas = new YmtProductActivityStockWapper();
		for (String pid : productids) {
			pas.updateStock0ByProductId(pid);
		}
	}
	/**
	 * 批量更新商品的活动库存为0 -mssql Ymt_ProductActivityStock->mongo YmtProducts ActivityProducts
	 * 注意只会更新商品查出的第一个活动规格
	 * @param productids 
	 * @param acctivityid 活动id 
	 * @throws Exception 
	 */
	public static void updateActivityStock0AndSync(List<String> productids,Integer acctivityid) throws Exception {
		YmtProductActivityStockWapper pas = new YmtProductActivityStockWapper();
		for (String pid : productids) {
			ProductManagerCallServiceV2.updateProductTimeStamp(pid);
			pas.updateStock0ByProductId(pid);
			Map ymtProductActivityStock= pas.selectBy(MapUtil.hashMap("sproductid",pid));
			ProductManagerCallServiceV3.productMongocrudSync(pid, "SyncLiveActivityProduct",Integer.valueOf(ymtProductActivityStock.get("iProductInActivityId").toString()));
//			new MongocrudCall().callAndGetReturnData(acctivityid,pid,"SyncLiveActivityProduct");
		}
	}
	/**
	 * 批量删除商品
	 * 
	 * @param productIds
	 * @param sellerId
	 * @return
	 * @throws Exception
	 */
	public static JsonObject batchDeleteProducts(List<String> productIds, Integer sellerId) throws Exception {
		BatchDeleteProductsCall batchDeleteProductsCall = new BatchDeleteProductsCall();
		BatchDeleteProductsBean BatchDeleteProductsBean = new BatchDeleteProductsBean();
		BatchDeleteProductsBean.setUserId(sellerId);
		BatchDeleteProductsBean.setProductIds(productIds);
		batchDeleteProductsCall.setData(false, BatchDeleteProductsBean);
		batchDeleteProductsCall.callService();
		return batchDeleteProductsCall.getJsonObject();
	}

	/**
	 * 下架全部商品
	 * 
	 * @param sellerId
	 * @throws Exception
	 */
	public static void offSaleAllProduct(Integer sellerId) throws Exception {
		List<String> plist = getAllOnSaleProducts(sellerId);
		updateActivityStock0(plist);
		for (String pid : plist) {
			// 批量下架很慢得一個個下架
			batchSetProductOffSale(Arrays.asList(pid), sellerId);
		}
	}

	/**
	 * 下架全部商品
	 * 
	 * @param sellerId
	 * @param isforceoff
	 *            强制下架ture的话会直接更新商品action为-1
	 * @throws Exception
	 */
	public static void offSaleAllProduct(Integer sellerId, Boolean isforceoff) throws Exception {
		if (isforceoff) {
			YmtProductsIWapper YmtProductsIWapper = new YmtProductsIWapper();
			List<String> plist = getAllOnSaleProducts(sellerId);
			for (String pid : plist) {
				YmtProductsIWapper.updateProductAction(pid, -1);
			}
		} else {
			offSaleAllProduct(sellerId);
		}

	}

	/**
	 * 商品加入扫货现场
	 * @throws IOException 
	 * @throws ClientProtocolException 
	 */
	public static void addProductInLives(Integer liveId,List<String> products,Integer sellerId) throws ClientProtocolException, IOException{
		AddProductInLivesBean addProductInLivesBean = new AddProductInLivesBean();
		addProductInLivesBean.setActivityId(liveId);
		addProductInLivesBean.setProductIds(products);
		addProductInLivesBean.setUserId(sellerId);
		AddProductInLivesCall addProductInLivesCall = new AddProductInLivesCall();
		addProductInLivesCall.setData(addProductInLivesBean);
		addProductInLivesCall.callService();
	}
	
	/**
	 * 更新product action -1 为已删除
	 * 
	 * @param pid
	 * @param action
	 */
	public static void updateProductAction(String pid, int action) {
		Logger.comment(pid + ":action更新为-1");
		new YmtProductsIWapper().updateProductAction(pid, -1);
	}

	/**
	 * 尽可能的上架商品
	 * 
	 * @param sellerId
	 * @throws Exception
	 */
	public static void onSaleAllProduct(Integer sellerId) throws Exception {
		boolean offsale = true;
		while (offsale) {
			List<String> plist = getProducts(sellerId, 4);
			// updateActivityStock0(plist);
			JsonObject jo = batchSetProductOnSale(plist, sellerId);
			JsonElement rpl = jo.get("Data").getAsJsonObject().get("ProductList");
			if (plist.size() <= 0 || rpl == null || rpl.isJsonNull()) {
				offsale = false;
			}
		}
	}

	/**
	 * 发布商品 使用第三方直邮物流
	 * com.ymatou.iapi.productmanager/AddSellerProductCall/addsellerproductcalltpl.json
	 * 
	 * @param sellerName
	 * @param sellerId
	 * @param stockNum
	 * @return
	 * @throws JSONException
	 * @throws IOException
	 * @throws ClientProtocolException
	 */
	@Deprecated
	public static String getNewProductId(String sellerName, int sellerId, int stockNum) throws JSONException, ClientProtocolException, IOException {
		Map updateMap = new HashMap();
		updateMap.put("product->catalogList[0]->stock", stockNum);
		updateMap.put("product->catalogStatus", 7);
		updateMap.put("sellerName", sellerName);
		updateMap.put("sellerId", sellerId);
		String proId = "";
		String fullPath = "com.ymatou.iapi.productmanager/AddSellerProductCall/addsellerproductcalltpl.json";
		JSONObject addProductBean = JsonBeanHelper.getJsonBean(fullPath);
		JsonBeanHelper.updateJsonBean(addProductBean, updateMap);
		Logger.debug("addProductBean:" + addProductBean.toString());
		// JSONObject jo =new
		// AddSellerProductCall().callAndGetReturnData(addProductBean);
		AddSellerProductCall call = new AddSellerProductCall();
		call.callService();
		JSONObject jo = new JSONObject(call.getReturnData());
		try {
			if (jo.getString("Msg").contains("发布权限")) {
				Logger.comment("添加发布权限0:" + sellerId);
				new SellerWapperV2().insertYmtExpressSellerToMode(sellerId, 7);
				Thread.sleep(5000);
				proId = ProductManagerCallServiceV2.addNewProductOnSale(sellerId, sellerName, updateMap);
			} else {
				proId = ProductManagerCallServiceV2.addNewProductOnSale(sellerId, sellerName, updateMap);
			}

		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		return proId;

	}

	/**
	 * 创建商品
	 * 
	 * @param updateMap
	 * @return
	 * @throws Exception
	 */
	@Deprecated
	public static JSONObject addNewProduct(Map<String, Object> updateMap) throws Exception {
		Logger.comment("变更参数:" + updateMap.toString());
		String fullPath = "com.ymatou.iapi.productmanager/AddSellerProductCall/addsellerproductcalltpl.json";
		JSONObject addProductBean = JsonBeanHelper.getJsonBean(fullPath);
		addProductBean = JsonBeanHelper.updateJsonBean(addProductBean, updateMap);
		// addProductBean.getJSONObject("product").setString("catalogId")="11";
		return addNewProduct(addProductBean);
		//return ProductManagerCallServiceV3.AddSellerProduct(addProductBean);
	}

	/**
	 * 创建商品
	 * 
	 * @param jsonbean
	 * @return
	 * @throws Exception
	 */
	@Deprecated
	public static JSONObject addNewProduct(JSONObject jsonbean) throws Exception {
		AddSellerProductCall addproduct = new AddSellerProductCall();
		// mock:mock-enable
		// mock-id:1
		// mock-api.1:orderdelivery-GetAvailableDeliveryMethod-Normal
		// mock-param.1.XloboBondedAreas:[1,2,3]
		addproduct.addHeader("mock", "mock-enable");
		addproduct.addHeader("mockId-1", TestDataManager.getRandomUUID().toString());
		addproduct.addHeader("mockApi-1", "orderdelivery-GetAvailableDeliveryMethod-Normal");
		
		//add by summing 20201223
        //物流权限2
		addproduct.addHeader("mockId-2", "GUID");
		addproduct.addHeader("mockApi-2", "orderdelivery-GetAvailableDeliveryMethodV2-Normal");
        //自动巡检
		addproduct.addHeader("mockId-3", "GUID");
		addproduct.addHeader("mockApi-3", "Violate-autoPreViolateProduct-Normal");
        //买手专项权限
		addproduct.addHeader("mockId-4", "GUID");
		addproduct.addHeader("mockApi-4", "sellerallocation-checkSellerSpecialPermission-Normal");
        //发商品的数量
		addproduct.addHeader("mockId-5", "GUID");
		addproduct.addHeader("mockApi-5", "SellerService-getSellerSeat-Normal");
		
		// addproduct.addHeader("mock-param.1.XloboBondedAreas",FormatUtil.urlEncode("[1,3]"));
		Logger.debug(addproduct.getReqHeader());
		addproduct.setData(jsonbean);
		addproduct.callService();
		if (addproduct.getString("Code").equals("400")) {
			// 查询接口异常会导致可能发布失败
			Thread.sleep(1000);
			addproduct.callService();
		}
		return new JSONObject(addproduct.getReturnData());
		// return addproduct.getJsonObject();

	}

	/**
	 * 初始化商品map
	 * 
	 * @return
	 */
	@Deprecated
	public static Map initCreateProductMap(Integer sellerId) {
		Map updateMap = new HashMap();
		updateMap.put("product->catalogList[0]->stock", 10);
		updateMap.put("product->catalogStatus", 7);
		String sellerName = new JUserWapper().selectUserinfoByUid(sellerId).get(0).getLoginId();
		updateMap.put("sellerName", sellerName);
		updateMap.put("sellerId", sellerId);

		updateMap.put("product->onSaleType", 0);
		updateMap.put("product->catalogStatus", 7);
		updateMap.put("product->productName", sellerId + "_AutoTest_" + YMTDateUtil.getSysTime("yyyyMMddHHmmssSSS"));
		return updateMap;
	}

	/**
	 * 添加上架商品
	 * 
	 * @param sellerId
	 * @param sellerName
	 * @param updateMap
	 * @return productid
	 * @throws Exception
	 */
	@Deprecated
	public static String addNewProductOnSale(int sellerId, String sellerName, Map<String, Object> updateMap) throws Exception {
		Map<String, Object> jsonbean = updateMap;
		if (jsonbean == null)
			jsonbean = new HashMap<String, Object>();

		jsonbean.put("sellerId", sellerId);
		jsonbean.put("sellerName", sellerName);

		jsonbean.put("product->onSaleType", 0);
		jsonbean.put("product->catalogStatus", 7);
		jsonbean.put("product->productName", "自动化测试_立即上架商品 " + YMTDateUtil.getSysTime("yyyyMMddHHmmss"));
		return addNewProduct(jsonbean).getJSONObject("Data").getString("ProductId");
	}

	/**
	 * 获取规格列表
	 * @param productId
	 * @return
	 */
	public static List<String> getCatalogList(String productId) {
		Logger.debug("查询商品");
		JSONObject prodDetail = new GetProductInfoByProductIdCall().callAndGetReturnData(productId);

		ProductInDetailBean prodBean = null;
		List<String> catalogList = new ArrayList<>() ;
		try {
			prodBean = ProductQueryCallService.getBeanFromJson(prodDetail.getJSONObject("Data").getJSONObject("Product"), ProductInDetailBean.class);
			catalogList=prodBean.getCatalogList().stream().map(x -> x.getCatalogId()).collect(Collectors.toList());
		} catch (Throwable e) {
			try {
				Thread.sleep(1000);
				prodBean = ProductQueryCallService.getBeanFromJson(prodDetail.getJSONObject("Data").getJSONObject("Product"), ProductInDetailBean.class);
				catalogList=prodBean.getCatalogList().stream().map(x -> x.getCatalogId()).collect(Collectors.toList());
			} catch (Exception e1) {
				e1.printStackTrace();
			}
		}
		return catalogList;
	}
	public static JsonObject addNewProductOnSale(AddSellerProductRequest addProdReq ) throws Exception {
		
		
		addProdReq.getProduct().setOnSaleType(0);
		addProdReq.getProduct().setCatalogStatus(10);
		addProdReq.getProduct().setDeliveryCompanyType(2);
		addProdReq.getProduct().setDeliveryAging(20);
		
		// 如果发布人为3383
		if (addProdReq.getSellerId() == 3383) {

			addProdReq.getProduct().setDeliveryAging(15);

			addProdReq.getProduct().getCatalogList().forEach(item -> {

				item.setMarketPrice(6000d);
				item.setPrice(4000d);
				item.setVipPrice(0.0d);
				item.setNewPrice(0.0d);
			});
		}
		
		return addNewProduct(addProdReq) ;
		
//		Map<String, Object> jsonbean = updateMap;
//		if (jsonbean == null)
//			jsonbean = new HashMap<String, Object>();
//
//		jsonbean.put("sellerId", sellerId);
//		jsonbean.put("sellerName", sellerName);
//
//		jsonbean.put("product->onSaleType", 0);
//		jsonbean.put("product->catalogStatus", 7);
//		jsonbean.put("product->productName", "自动化测试_立即上架商品 " + YMTDateUtil.getSysTime("yyyyMMddHHmmss"));
//		return addNewProduct(jsonbean).getJSONObject("Data").getString("ProductId");
	}
	/**
	 * 商品物流限制 1：国家物流配送方式 对应表 YmtRelease.dbo.Ymt_ExpressCountryToMode 2：买手物流配送方式
	 * YmtRelease.dbo.Ymt_BondedUserToArea iCatalogStatus(5贝海保税区，4买手保税区)
	 * ibondedAreaID (保税区ID(1-10))
	 * 
	 * @param sellerId
	 *            买手Id
	 * @param catalogStatus
	 *            物流方式
	 * @param areasId
	 *            (保税区ID(1-10))
	 * @throws InterruptedException
	 */
	public static void DeliveryMethodInfo(Integer sellerId, int catalogStatus, int areasId) throws InterruptedException {
		YmtSellerInfoWapper sellerInfo = new YmtSellerInfoWapper();
		Ymt_ExpressSellerToModeWapper sellerToModeWapper = new Ymt_ExpressSellerToModeWapper();
		Ymt_ExpressCountryToModeWapper countryToModeWapper = new Ymt_ExpressCountryToModeWapper();

		Map map = sellerInfo.getSellerInfoBySellerId(sellerId).get(0);

		List<Map> countryToModeList = countryToModeWapper.selectbyCountryId(Integer.parseInt(map.get("iLiveCountry").toString()));
		if (countryToModeList.size() == 0)// 国家物流配送方式
		{
			Ymt_ExpressCountryToMode record = new Ymt_ExpressCountryToMode();
			record.setCountryId(Integer.parseInt(map.get("ilivecountry").toString()));
			record.setCatalogStatus(catalogStatus);
			record.setPriceLimit(new BigDecimal(1));
			record.setFreightTemplateSwitch(true);
			countryToModeWapper.insert(record);
		}

		List<Map> sellerToModeList = sellerToModeWapper.selectbySellerId(sellerId);
		if (sellerToModeList.size() == 0)// 买手物流配送方式
		{
			Ymt_ExpressSellerToMode record = new Ymt_ExpressSellerToMode();
			record.setSellerId(Integer.parseInt(map.get("SellerId").toString()));
			record.setCatalogStatus(catalogStatus);
			record.setHasAvailable(true);
			sellerToModeWapper.insert(record);
		}
		if (catalogStatus == 4 || catalogStatus == 5)// 4买手保税区,5贝海保税区
		{
			Ymt_BondedAreaWapper bondedAreaWapper = new Ymt_BondedAreaWapper();
			List<Ymt_BondedArea> bondedArealist = bondedAreaWapper.selectByCatalogStatus(catalogStatus);
			if (bondedArealist.size() == 0) {
				Ymt_BondedArea area = new Ymt_BondedArea();
				area.setiCatalogStatus(catalogStatus);
				area.setsBondedAreaNameCn("广州保税区");
				area.setsBondedAreaNameEn("GuangZhou Bonded Area");
				bondedAreaWapper.insert(area);
			}
		}
	}

	/**
	 * 发布一个5天前自动上架的商品
	 * 
	 * @param sellerId
	 * @param sellerName
	 * @param updateMap
	 * @return
	 * @throws Exception
	 */
	@Deprecated
	public static JSONObject addNewProduct5dayago(int sellerId, String sellerName, Map<String, Object> updateMap) throws Exception {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("sellerName", sellerName);
		map.put("sellerId", sellerId);
		// //拼邮
		map.put("product->catalogStatus", 5);
		// 使用原时间 影响validStart validEnd
		map.put("product->onSaleType", 1);
		// 设置自动上架
		map.put("product->autoRefresh", true);
		map.put("product->productName", "自动化测试_定时上架商品 " + YMTDateUtil.getBeforeOrNextDay(0));
		// 设为为过去5天前发布的商品
		Calendar c = Calendar.getInstance();
		c.add(Calendar.DAY_OF_MONTH, -5);
		map.put("product->validStart", sdf.format(c.getTime()));

		c.add(Calendar.DAY_OF_MONTH, 10);
		map.put("product->validEnd", sdf.format(c.getTime()));

		if (updateMap != null) {
			map.putAll(updateMap);
		}
		return addNewProduct(map);

	}

	/**
	 * 发布FBX商品（单规格） product->catalogType", 2
	 * 
	 * @param updateMap
	 * @return 返回商品ID
	 * @throws Exception
	 * 
	 */
	@Deprecated
	public static String addFBXProduct(Map<String, Object> updateMap) throws Exception {
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("product->catalogType", 2);
		map.put("product->productName", "自动化测试_定时上架商品 " + YMTDateUtil.getBeforeOrNextDay(0));
		if (updateMap != null) {
			map.putAll(updateMap);
		}
		JSONObject ob = addNewProduct(map);
		return ob.getJSONObject("Data").getString("ProductId");
	}

	/***
	 * 修改所有规格库存为0
	 * updateAllProductStockNumV2
	 */
	@Deprecated
	public static void updateAllStockNumAs0(int sellerId, String productId) throws Exception {
		new YmtCatalogsIWapper().selectCatalogsByProductId(productId).forEach(prodInfo -> {
			String catalogId = prodInfo.getsCatalogId();
			try {
				updateProductStockNum(sellerId, productId, catalogId, 0);
			} catch (Exception e) {
				e.printStackTrace();
			}
		});
		Thread.sleep(2000);
	}

	/***
	 * 修改商品库存
	 * updateProductStockNumV2
	 * @param sellerId
	 * @param prodId
	 * @param catalogId
	 * @param num
	 * @return
	 * @throws Exception
	 */
	@Deprecated
	public static boolean updateProductStockNum(int sellerId, String prodId, String catalogId, int num) throws Exception {
		UpdateProductCatalogsCall updateProductCatalogsCall = new UpdateProductCatalogsCall();
		Map<String, Object> updateMap = new HashMap<String, Object>();
		updateMap.put("Catalogs[0]->UserId", sellerId);
		updateMap.put("UserID", sellerId);
		updateMap.put("ProductID", prodId);
		updateMap.put("Catalogs[0]->CatalogId", catalogId);
		updateMap.put("Catalogs[0]->Num", num);

		return updateProductCatalogsCall.callAndGetReturnData(updateMap).get("Code").toString().equals("200");
	}
	/**
	 * 更新规格库存
	 * @param productId
	 * @param sellerId
	 * @param catalogId
	 */
	public static void updateProductStockNumV2(int sellerId, String productId, String catalogId, int num) {
		UpdateProductCatalogsBean updateProductCatalogsBean = new UpdateProductCatalogsBean();
		UpdateProductCatalogsCall updateProductCatalogsCall = new UpdateProductCatalogsCall();
		updateProductCatalogsBean.setProductID(productId);
		updateProductCatalogsBean.setUserID(sellerId);
		UpdateProductCatalogDto updateCatalogDto = new UpdateProductCatalogDto();
		updateCatalogDto.setCatalogId(catalogId);
		updateCatalogDto.setUserId(sellerId);
		updateCatalogDto.setNum(num);
		updateProductCatalogsBean.setCatalogs(Arrays.asList(updateCatalogDto));
		updateProductCatalogsCall.callAndGetReturnData(updateProductCatalogsBean);
	}

	/**
	 * 更新所有规格库存
	 * @param sellerId
	 * @param productId
	 * @param num
	 * @throws InterruptedException
	 */
	public static void updateAllProductStockNumV2(int sellerId, String productId, int num) throws InterruptedException {
		new YmtCatalogsIWapper().selectCatalogsByProductId(productId).forEach(prodInfo -> {
			String catalogId = prodInfo.getsCatalogId();
			try {
				 updateProductStockNumV2(sellerId, productId, catalogId, num);
			} catch (Exception e) {
				e.printStackTrace();
			}
		});
		Thread.sleep(2000);
	}
	/***
	 * 添加商品到直播
	 * 
	 * @param userId
	 * @param liveId
	 * @param productId
	 * @return
	 * @throws ClientProtocolException
	 * @throws JSONException
	 * @throws IOException
	 */
	public static JSONObject addProductInLive(int userId, int liveId, String productId) throws ClientProtocolException, JSONException, IOException {
		List<String> productIdsList = new ArrayList<String>();
		productIdsList.add(productId);
		JSONObject ret = addProductsInLive(userId, liveId, productIdsList);
		return ret;
	}

	/***
	 * 添加商品组到直播
	 * 
	 * @param userId
	 * @param liveId
	 * @param productIdsList
	 * @return
	 * @throws JSONException
	 * @throws ClientProtocolException
	 * @throws IOException
	 */
	public static JSONObject addProductsInLive(int userId, int liveId, List<String> productIdsList) throws JSONException, ClientProtocolException, IOException {

		Map<String, Object> updateMap = new HashMap<String, Object>();
		updateMap.put("UserId", userId);
		updateMap.put("ActivityId", liveId);
		updateMap.put("ProductIds", new JSONArray(productIdsList.toString()));

		JSONObject jsonObject = JsonBeanHelper.getJsonBean(JsonBeanFile.AddProductInLivesTpl);
		JsonBeanHelper.updateJsonBean(jsonObject, updateMap);

		JSONObject ret = new AddProductInLivesCall().callAndGetReturnData(jsonObject);

		if (YmtMongoDriverFactroy.isEsCheck()) {
			productIdsList.forEach(productId -> new EsCall().callAndGetReturnData(0, productId, "UpdateLiveTimeForEs"));
		}

		return ret;

	}

	/**
	 * 创建商品
	 * @param sellerId
	 * @param sellerName
	 * @param pnum
	 * @return
	 * @throws Exception
	 */
	public static List<Map> createProducts(Integer sellerId, String sellerName, Integer pnum) throws Exception {
		List<Map> mpids = new ArrayList<Map>();

		// 创建商品限制
		// SELECT TOP 1000 [ID]
		// ,[SellerID]
		// ,[ProductPits]
		// ,[CreateTime]
		// ,[LastUpdateTime]
		// FROM [YmtSellerReport].[dbo].[ymt_sellerproductpits] where
		// sellerid=21159026
		Logger.debug("创建商品");

		for (int i = 0; i < pnum; i++) {
			String productId = ProductManagerCallServiceV2.getStgProductId(sellerName, sellerId, 999999,null);
			Thread.sleep(2000);
			Map map = new HashMap<>();
			map.put("productId", productId);
			map.put("sellerId", sellerId);
			map.put("sellerName", sellerName);
			mpids.add(map);
		}
		mpids.forEach(map2 -> {
			String productId = map2.get("productId").toString();
			Logger.debug("查询商品");
			JSONObject prodDetail = new GetProductInfoByProductIdCall().callAndGetReturnData(productId);
			ProductInDetailBean prodBean = null;
			try {
				prodBean = ProductQueryCallService.getBeanFromJson(prodDetail.getJSONObject("Data").getJSONObject("Product"), ProductInDetailBean.class);
			} catch (JSONException e) {
				e.printStackTrace();
			}
			List<String> catalogList = prodBean.getCatalogList().stream().map(x -> x.getCatalogId()).collect(Collectors.toList());
			// for (String catalog : catalogList) {
			// TestDataManager.appendFileToLine(logfile, sellerId + ":" +
			// productId + ":" + catalog);
			// }
			// TestDataManager.appendFileToLine(logfile, sellerId + ":创建商品:" +
			// productId + ":catalogList:" + catalogList);
			map2.put("catalogList", catalogList);
		});
		return mpids;
	}

	/**
	 * 产线压测用 获取这个用户的所有在售商品
	 * 
	 * @param sellerId
	 * @param sellerName
	 * @return map.put("productId", productId); map.put("sellerId", sellerId);
	 *         map.put("sellerName", sellerName); map.put("catalogList",
	 *         catalogList);
	 * @throws Exception
	 */
	public static List<Map> getProducts(Integer sellerId, String sellerName) throws Exception {
		List<Map> mpids = new ArrayList<Map>();
		List<String> alllist = ProductManagerCallServiceV2.getAllOnSaleProducts(sellerId);
		for (String productId : alllist) {
			JSONObject prodDetail = new GetProductInfoByProductIdCall().callAndGetReturnData(productId);
			ProductInDetailBean prodBean = ProductQueryCallService.getBeanFromJson(prodDetail.getJSONObject("Data").getJSONObject("Product"), ProductInDetailBean.class);
			Logger.debug(FormatUtil.beanToGSONString(prodBean));
			if (prodBean.getCatalogList().size() == 10 && prodBean.getCatalogList().get(0).getPrice().equals(price)) {
				List<String> catalogList = prodBean.getCatalogList().stream().map(x -> x.getCatalogId()).collect(Collectors.toList());
				// for (String catalog : catalogList) {
				// TestDataManager.appendFileToLine(logfile, sellerId + ":" +
				// productId + ":" + catalog);
				// }
				// TestDataManager.appendFileToLine(logfile, sellerId + ":" +
				// productId + ":" + catalogList.get(0));
				Map map = new HashMap<>();
				map.put("productId", productId);
				map.put("sellerId", sellerId);
				map.put("sellerName", sellerName);
				map.put("catalogList", catalogList);
				mpids.add(map);
			}
		}
		return mpids;
	}
	
	
	/**
	 * 获取商品简表
	 */
	public static JsonObject GetProductListByProductIdList(String productId) throws Exception {
		GetProductListByProductIdListBean GetProductListByProductIdListBean = new GetProductListByProductIdListBean();
		GetProductListByProductIdListCall getProductListByProductIdListCall = new GetProductListByProductIdListCall();
		GetProductListByProductIdListBean.setNextActivityExpire(1);
		GetProductListByProductIdListBean.setProductIdList(Arrays.asList(productId));
		getProductListByProductIdListCall.setData(GetProductListByProductIdListBean);
		getProductListByProductIdListCall.callService();
		return getProductListByProductIdListCall.getJsonObject().get("Data").getAsJsonObject()
				.getAsJsonArray("ProductList").get(0).getAsJsonObject();
	}

	/**
	 * 获取用户所有在售商品和规格
	 * 
	 * @param sellerId
	 * @return map{productid:catalogs}
	 * @throws Exception
	 */
	public static Map<String, List<String>> getOnSaleProductsAndCatalogs(Integer sellerId) throws Exception {
		Map<String, List<String>> map = new HashMap<String, List<String>>();
		List<String> alllist = ProductManagerCallServiceV2.getAllOnSaleProducts(sellerId);
		for (String productId : alllist) {
			JSONObject prodDetail = new GetProductInfoByProductIdCall().callAndGetReturnData(productId);
			ProductInDetailBean prodBean = ProductQueryCallService.getBeanFromJson(prodDetail.getJSONObject("Data").getJSONObject("Product"), ProductInDetailBean.class);
			Logger.debug(FormatUtil.beanToGSONString(prodBean));
			List<String> catalogList = prodBean.getCatalogList().stream().map(x -> x.getCatalogId()).collect(Collectors.toList());
			map.put(productId, catalogList);
		}
		return map;
	}

	/**
	 * 初始化规格bean
	 * 
	 * @return
	 */
	public static CatalogSaveModel initCatalogSaveModel() {
		CatalogSaveModel CatalogSaveModel = new CatalogSaveModel();
		// "operateType": 1,
		// "weight": null,
		// "isPackage": false,
		// "isPreSale": false,
		// "subCatalogIdList": null,
		// "newPrice": 12,
		// "catalogId": "",
		// "productCode": null,
		// "multiLogistics": 0,
		// "price": 12,
		// "vipPrice": 12,
		// "action": 0,
		// "stock": 12,
		// "sku": null
		CatalogSaveModel.setOperateType(1);
		CatalogSaveModel.setPackage(false);
		CatalogSaveModel.setPreSale(false);
		CatalogSaveModel.setNewPrice(Integer.valueOf(price));
		CatalogSaveModel.setVipPrice(Integer.valueOf(price));
		CatalogSaveModel.setPrice(Integer.valueOf(price));
		CatalogSaveModel.setMarketPrice(70);
		CatalogSaveModel.setAction(0);
		CatalogSaveModel.setStock(1000000);
		CatalogSaveModel.setMultiLogistics(0);
		CatalogSaveModel.setSku("sku-7232f1de-ffbf-49ae-a0bc-d8765456b07f");

		List<CatalogPropertySaveModel> propertyList = new ArrayList<>();
		CatalogPropertySaveModel e1 = new CatalogPropertySaveModel();
		// e.setPropertyId("1");
		e1.setPropertyName("颜色");
		e1.setPropertyUrl("http://s2.ymatou.com/home/b5abefb15e5afbb91d82c65df819be22.png");
		e1.setPropertyValue("红色");
		propertyList.add(e1);
		CatalogSaveModel.setPropertyList(propertyList);
		return CatalogSaveModel;
	}

	/**
	 * 初始化规格设置
	 * 
	 * @param allprice
	 * @param Stock
	 * @param PropertyName
	 * @param PropertyValue
	 * @return
	 */
	public static CatalogSaveModel initCatalogSaveModel(double allprice, int Stock, String PropertyName, String PropertyValue) {
		CatalogSaveModel CatalogSaveModel = new CatalogSaveModel();
		// "operateType": 1,
		// "weight": null,
		// "isPackage": false,
		// "isPreSale": false,
		// "subCatalogIdList": null,
		// "newPrice": 12,
		// "catalogId": "",
		// "productCode": null,
		// "multiLogistics": 0,
		// "price": 12,
		// "vipPrice": 12,
		// "action": 0,
		// "stock": 12,
		// "sku": null
		CatalogSaveModel.setOperateType(1);
		CatalogSaveModel.setPackage(false);
		CatalogSaveModel.setPreSale(false);
		CatalogSaveModel.setNewPrice(allprice);
		CatalogSaveModel.setVipPrice(allprice);
		CatalogSaveModel.setPrice(allprice);
		CatalogSaveModel.setAction(0);
		CatalogSaveModel.setStock(Stock);
		CatalogSaveModel.setMultiLogistics(0);

		List<CatalogPropertySaveModel> propertyList = new ArrayList<>();
		CatalogPropertySaveModel e1 = new CatalogPropertySaveModel();
		// e.setPropertyId("1");
		e1.setPropertyName(PropertyName);
		e1.setPropertyUrl("http://s2.ymatou.com/home/b5abefb15e5afbb91d82c65df819be22.png");
		e1.setPropertyValue(PropertyValue);
		propertyList.add(e1);
		CatalogSaveModel.setPropertyList(propertyList);
		return CatalogSaveModel;

	}

	/**
	 * 验证商品奢品
	 * @param productId
	 * @param luxury
	 * @throws InterruptedException
	 */
	public static void EqualsIsLuxury(String productId,boolean luxury) throws InterruptedException {
		List<YmtProductsI> selectProductByProductId = new YmtProductsIWapper().selectProductByProductId(productId);
		List<YmtCatalogsI> selectCatalogsByProductId = new YmtCatalogsIWapper().selectCatalogsByProductId(productId);
		
		boolean luxury2 = selectProductByProductId.get(0).isLuxury();
		List<YmtCatalogsI> collect = selectCatalogsByProductId.stream().filter(b->(b.isLuxury()==luxury)).collect(Collectors.toList());
		Logger.verifyEquals(true, collect.size()>=1, "验证规格至少有一个匹配"+collect.toString());
		Logger.verifyEquals(luxury, luxury2, "验证商品奢品状态为"+luxury);
		
	}

	/**
	 * 初始化默认商品bean
	 * 
	 * @param sellerId
	 * @return
	 */
	public static AddSellerProductRequest initAddSellerProductRequest(int sellerId) {
		AddSellerProductRequest AddSellerProductRequest = new AddSellerProductRequest();
		// 最外层
		AddSellerProductRequest.setSellerId(sellerId);
		String sellerName = new JUserWapper().selectUserinfoByUid(sellerId).get(0).getLoginId();
		AddSellerProductRequest.setSellerName(sellerName);
		AddSellerProductRequest.setProductSite("PC");
		// ProductSaveModel 外层
		ProductSaveModel productSaveModel = new ProductSaveModel();
		productSaveModel.setSellerId(sellerId);
		productSaveModel.setSellerLoginId(sellerName);
		productSaveModel.setProductType(0);
		productSaveModel.setProductName("测试山沟" + YMTDateUtil.getDate().getTime());
		productSaveModel.setLiveIdList(null);
		// 二级类目编号
		productSaveModel.setSecondCategoryId(1002);
		// 三级类目编号
		productSaveModel.setThirdCategoryId(1003);
		// 标准品牌编号
		productSaveModel.setBrandId(ProductManagerCallServiceV3.BrandId);
		// 标准品牌名称
		productSaveModel.setBrandName("耐克Nike");
		// 商品图片列表
		
		/*List<String> picList = Arrays.asList("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701_400_401_n_w_l.jpg",
				"http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701_400_401.jpg",
				"http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701.jpg");*/
		List<String> picList = new ArrayList<>();
		picList.add("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701_400_401_n_w_l.jpg");
		picList.add("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701_400_401.jpg");
		picList.add("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701.jpg");
		productSaveModel.setProductPicList(picList);
		// 物流方式
		productSaveModel.setCatalogStatus(4);
		productSaveModel.setNoticeRisk(true);

		String validStart = YMTDateUtil.getBeforeOrNextDay(0, YMTDateUtil.YMDHMS);
		String validEnd = YMTDateUtil.getBeforeOrNextDay(7, YMTDateUtil.YMDHMS);
		// 商品的起始有效期
		productSaveModel.setValidStart(validStart);
		// 商品上架结束有效期
		productSaveModel.setValidEnd(validEnd);
		// 自动延期标识
		productSaveModel.setAutoRefresh(false);
		// 备货类型（0-现货，1-扫货，2- FBX）
		productSaveModel.setCatalogType(0);
		// 包税方式（交税方 0. 卖家交税，1. 买家交税,） default = 0 默认传 0
		productSaveModel.setTariffType(0);
		// 保税区
		productSaveModel.setBondedArea(7);
		// 保税商品备案号
		productSaveModel.setProductCode("Test" + YMTDateUtil.getDate());
		// 七天无理由退货
		productSaveModel.setNoReasonReturn(false);
		// 多物流方式（0-不支持，3-贝海直邮）
		productSaveModel.setMultiLogistics(0);
		// 多物流差价
		productSaveModel.setFlightBalance(0);
		productSaveModel.setWeightUnit(2);
		// 上架销售类型-1, 原时间 0, 立即上架 1, 定时上架 2, 发布但不上架 3, 按直播时间上架
		productSaveModel.setOnSaleType(0);
		// 来源
		productSaveModel.setSourceType("PC");
		// productSaveModel.setSellerCountryId();
		// 发布（true） & 编辑（false） 商品坑位计算使用，可不作为参数传入
		productSaveModel.setReleaseProduct(true);
		// 选填，长度限定为700个字符
		productSaveModel.setRemark("Testzhaxina" + YMTDateUtil.getDate());

		// 规格1
		CatalogSaveModel catalogSaveModel1 = new CatalogSaveModel();
		catalogSaveModel1.setOperateType(1);
		catalogSaveModel1.setPackage(false);
		catalogSaveModel1.setPreSale(false);
		// 规格新客价
		String newPrice = "8";
		catalogSaveModel1.setNewPrice(Integer.valueOf(newPrice));
		// 规格vip价格
		String vipPrice = "12";
		catalogSaveModel1.setVipPrice(Integer.valueOf(vipPrice));
		// 商品原价
		String price = "16";
		catalogSaveModel1.setPrice(Integer.valueOf(price));
		// BigDecimal marketPrice = new BigDecimal(20);
		String marketPrice = "20";
		catalogSaveModel1.setMarketPrice(Integer.valueOf(marketPrice));
		catalogSaveModel1.setAction(0);
		catalogSaveModel1.setStock(1000000);
		catalogSaveModel1.setMultiLogistics(0);
		catalogSaveModel1.setSku("sku-7232f1de-ffbf-49ae-a0bc-d8765456b07f");
		// 规格属性
		List<CatalogPropertySaveModel> propertyList = new ArrayList<>();
		CatalogPropertySaveModel e1 = new CatalogPropertySaveModel();
		e1.setPropertyName("颜色");
		e1.setPropertyUrl("http://s2.ymatou.com/home/b5abefb15e5afbb91d82c65df819be22.png");
		e1.setPropertyValue("红色");
		propertyList.add(e1);
		catalogSaveModel1.setPropertyList(propertyList);

		// 规格2
		CatalogSaveModel catalogSaveModel2 = new CatalogSaveModel();
		catalogSaveModel2.setOperateType(1);
		catalogSaveModel2.setPackage(false);
		catalogSaveModel2.setPreSale(false);
		// 规格新客价
		newPrice = "10";
		catalogSaveModel2.setNewPrice(Integer.valueOf(newPrice));
		// 规格vip价格
		vipPrice = "15";
		catalogSaveModel2.setVipPrice(Integer.valueOf(vipPrice));
		// 商品原价
		price = "20";
		catalogSaveModel2.setPrice(Integer.valueOf(price));
		String marketPrice1 = "30";
		catalogSaveModel2.setMarketPrice(Integer.valueOf(marketPrice1));
		catalogSaveModel2.setAction(0);
		catalogSaveModel2.setStock(1000000);
		catalogSaveModel2.setMultiLogistics(0);
		catalogSaveModel2.setSku("sku-7232f1de-ffbf-49ae-a0bc-d8765456b07f");
		// 规格属性
		List<CatalogPropertySaveModel> propertyList1 = new ArrayList<>();
		CatalogPropertySaveModel e2 = new CatalogPropertySaveModel();
		e2.setPropertyName("颜色");
		e2.setPropertyUrl("http://s2.ymatou.com/home/b5abefb15e5afbb91d82c65df819be22.png");
		e2.setPropertyValue("蓝色");
		propertyList1.add(e2);
		catalogSaveModel2.setPropertyList(propertyList1);

		List<CatalogSaveModel> catalogSaveModels = new ArrayList<>();
		catalogSaveModels.add(catalogSaveModel1);
		catalogSaveModels.add(catalogSaveModel2);
		productSaveModel.setCatalogList(catalogSaveModels);

		// 商品文描
		ProductDescSaveModel descModel = new ProductDescSaveModel();
		descModel.setDescription("商品文描");
		List<String> descPicList = new ArrayList<>();
		descPicList.add("http://s2.ymatou.com/home/4aa0780b5ffeee46a01f132052fdb71a.png");
		descPicList.add("http://s2.ymatou.com/home/4aa0780b5ffeee46a01f132052fdb71b.png");
		descPicList.add("http://s2.ymatou.com/home/4aa0780b5ffeee46a01f132052fdb71c.png");
		descPicList.add("http://s2.ymatou.com/home/4aa0780b5ffeee46a01f132052fdb71d.png");
		descPicList.add("http://s2.ymatou.com/home/4aa0780b5ffeee46a01f132052fdb71e.png");
		descModel.setDescPicList(descPicList);
		descModel.setBuyerNoticeId(0);
		descModel.setDeclarationId(0);
		descModel.setSellerServiceId(0);
		descModel.setSizeTemplateId(0);
		productSaveModel.setDescModel(descModel);

		// 商品关联运费模板
		List<ProductFreightSaveModel> freightTemplateList = new ArrayList<>();
		productSaveModel.setFreightTemplateList(freightTemplateList);

		// 商品视频 null
		productSaveModel.setVideoModel(null);

		// 商品属性
		List<ProductPropertySaveModel> productPropertySaveModels = new ArrayList<>();
		ProductPropertySaveModel e = new ProductPropertySaveModel();
		e.setPropertyId(1);
		List<String> propertyValues = new ArrayList<>();
		propertyValues.add("propertyValue1");
		propertyValues.add("propertyValue2");
		e.setPropertyValues(propertyValues);
		productPropertySaveModels.add(e);
		productSaveModel.setPropertyList(productPropertySaveModels);
		
		//recomReason  选填，推荐理由
		productSaveModel.setRecomReason("推荐理由_"+TestDataManager.getRandomIntNum(2));
		
		//物流信息 新增20201216
		productSaveModel.setPackageDeliveryType(0);
		productSaveModel.setDeliveryAging(5);
		productSaveModel.setDeliveryCompanyType(2);
		
		AddSellerProductRequest.setProduct(productSaveModel);
		return AddSellerProductRequest;
	}


	public static AddSellerProductRequest initAddSellerProductRequestV2(int sellerId) {
		AddSellerProductRequest AddSellerProductRequest = new AddSellerProductRequest();
		// 最外层
		AddSellerProductRequest.setSellerId(sellerId);
		String sellerName = new JUserWapper().selectUserinfoByUid(sellerId).get(0).getLoginId();
		AddSellerProductRequest.setSellerName(sellerName);
		AddSellerProductRequest.setProductSite("PC");
		// ProductSaveModel 外层
		ProductSaveModel productSaveModel = new ProductSaveModel();
		productSaveModel.setSellerId(sellerId);
		productSaveModel.setSellerLoginId(sellerName);
		productSaveModel.setProductType(0);
		productSaveModel.setProductName("测试山沟" + YMTDateUtil.getDate().getTime());
		productSaveModel.setLiveIdList(null);
		// 二级类目编号
		productSaveModel.setSecondCategoryId(1002);
		// 三级类目编号
		productSaveModel.setThirdCategoryId(1003);
		// 标准品牌编号
		productSaveModel.setBrandId(ProductManagerCallServiceV3.BrandId);
		// 标准品牌名称
		productSaveModel.setBrandName("耐克");
		// 商品图片列表
		/*List<String> picList = Arrays.asList("http://pc1.img.ymatou.com/G01/shangou/M00/2C/2D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701_400_401_n_w_l.jpg",
				"http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701_400_401.jpg",
				"http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701.jpg");*/
		List<String> picList = new ArrayList<>();
		picList.add("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701_400_401_n_w_l.jpg");
		picList.add("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701_400_401.jpg");
		picList.add("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701.jpg");
		productSaveModel.setProductPicList(picList);
		// 物流方式
		productSaveModel.setCatalogStatus(5);
		productSaveModel.setNoticeRisk(true);

		String validStart = YMTDateUtil.getBeforeOrNextDay(0, YMTDateUtil.YMDHMS);
		String validEnd = YMTDateUtil.getBeforeOrNextDay(7, YMTDateUtil.YMDHMS);
		// 商品的起始有效期
		productSaveModel.setValidStart(validStart);
		// 商品上架结束有效期
		productSaveModel.setValidEnd(validEnd);
		// 自动延期标识
		productSaveModel.setAutoRefresh(true);
		// 备货类型（0-现货，1-扫货，2- FBX）
		productSaveModel.setCatalogType(0);
		// 包税方式（交税方 0. 卖家交税，1. 买家交税,） default = 0 默认传 0
		productSaveModel.setTariffType(0);
		// 保税区
		productSaveModel.setBondedArea(7);
		// 保税商品备案号
		productSaveModel.setProductCode("Test" + YMTDateUtil.getDate());
		// 七天无理由退货
		productSaveModel.setNoReasonReturn(false);
		// 多物流方式（0-不支持，3-贝海直邮）
		productSaveModel.setMultiLogistics(0);
		// 多物流差价
		productSaveModel.setFlightBalance(0);
		productSaveModel.setWeightUnit(2);
		// 上架销售类型-1, 原时间 0, 立即上架 1, 定时上架 2, 发布但不上架 3, 按直播时间上架
		productSaveModel.setOnSaleType(0);
		// 来源
		productSaveModel.setSourceType("PC");
		// productSaveModel.setSellerCountryId();
		// 发布（true） & 编辑（false） 商品坑位计算使用，可不作为参数传入
		productSaveModel.setReleaseProduct(true);
		// 选填，长度限定为700个字符
		productSaveModel.setRemark("Testzhaxina" + YMTDateUtil.getDate());

		// 规格1
		CatalogSaveModel catalogSaveModel1 = new CatalogSaveModel();
		catalogSaveModel1.setOperateType(1);
		catalogSaveModel1.setPackage(false);
		catalogSaveModel1.setPreSale(false);
		// 规格新客价
		String newPrice = "8";
		catalogSaveModel1.setNewPrice(Integer.valueOf(newPrice));
		// 规格vip价格
		String vipPrice = "12";
		catalogSaveModel1.setVipPrice(Integer.valueOf(vipPrice));
		// 商品原价
		String price = "16";
		catalogSaveModel1.setPrice(Integer.valueOf(price));
		// BigDecimal marketPrice = new BigDecimal(20);
		String marketPrice = "20";
		catalogSaveModel1.setMarketPrice(Integer.valueOf(marketPrice));
		catalogSaveModel1.setAction(0);
		catalogSaveModel1.setStock(1000000);
		catalogSaveModel1.setMultiLogistics(0);
		catalogSaveModel1.setSku("sku-7232f1de-ffbf-49ae-a0bc-d8765456b07f");
		// 规格属性
		List<CatalogPropertySaveModel> propertyList = new ArrayList<>();
		CatalogPropertySaveModel e1 = new CatalogPropertySaveModel();
		e1.setPropertyName("颜色");
		e1.setPropertyUrl("http://s2.ymatou.com/home/b5abefb15e5afbb91d82c65df819be22.png");
		e1.setPropertyValue("红色");
		propertyList.add(e1);
		catalogSaveModel1.setPropertyList(propertyList);

		// 规格2
		CatalogSaveModel catalogSaveModel2 = new CatalogSaveModel();
		catalogSaveModel2.setOperateType(1);
		catalogSaveModel2.setPackage(false);
		catalogSaveModel2.setPreSale(false);
		// 规格新客价
		newPrice = "10";
		catalogSaveModel2.setNewPrice(Integer.valueOf(newPrice));
		// 规格vip价格
		vipPrice = "15";
		catalogSaveModel2.setVipPrice(Integer.valueOf(vipPrice));
		// 商品原价
		price = "20";
		catalogSaveModel2.setPrice(Integer.valueOf(price));
		String marketPrice1 = "30";
		catalogSaveModel2.setMarketPrice(Integer.valueOf(marketPrice1));
		catalogSaveModel2.setAction(0);
		catalogSaveModel2.setStock(1000000);
		catalogSaveModel2.setMultiLogistics(0);
		catalogSaveModel2.setSku("sku-7232f1de-ffbf-49ae-a0bc-d8765456b07f");
		// 规格属性
		List<CatalogPropertySaveModel> propertyList1 = new ArrayList<>();
		CatalogPropertySaveModel e2 = new CatalogPropertySaveModel();
		e2.setPropertyName("颜色");
		e2.setPropertyUrl("http://s2.ymatou.com/home/b5abefb15e5afbb91d82c65df819be22.png");
		e2.setPropertyValue("蓝色");
		propertyList1.add(e2);
		catalogSaveModel2.setPropertyList(propertyList1);

		List<CatalogSaveModel> catalogSaveModels = new ArrayList<>();
		catalogSaveModels.add(catalogSaveModel1);
		catalogSaveModels.add(catalogSaveModel2);
		productSaveModel.setCatalogList(catalogSaveModels);

		// 商品文描
		ProductDescSaveModel descModel = new ProductDescSaveModel();
		descModel.setDescription("商品文描");
		List<String> descPicList = new ArrayList<>();
		descPicList.add("http://s2.ymatou.com/home/4aa0780b5ffeee46a01f132052fdb71a.png");
		descPicList.add("http://s2.ymatou.com/home/4aa0780b5ffeee46a01f132052fdb71b.png");
		descPicList.add("http://s2.ymatou.com/home/4aa0780b5ffeee46a01f132052fdb71c.png");
		descPicList.add("http://s2.ymatou.com/home/4aa0780b5ffeee46a01f132052fdb71d.png");
		descPicList.add("http://s2.ymatou.com/home/4aa0780b5ffeee46a01f132052fdb71e.png");
		descModel.setDescPicList(descPicList);
		descModel.setBuyerNoticeId(0);
		descModel.setDeclarationId(0);
		descModel.setSellerServiceId(0);
		descModel.setSizeTemplateId(0);
		productSaveModel.setDescModel(descModel);

		// 商品关联运费模板
		List<ProductFreightSaveModel> freightTemplateList = new ArrayList<>();
		productSaveModel.setFreightTemplateList(freightTemplateList);

		// 商品视频 null
		productSaveModel.setVideoModel(null);

		// 商品属性
		List<ProductPropertySaveModel> productPropertySaveModels = new ArrayList<>();
		ProductPropertySaveModel e = new ProductPropertySaveModel();
		e.setPropertyId(1);
		List<String> propertyValues = new ArrayList<>();
		propertyValues.add("propertyValue1");
		propertyValues.add("propertyValue2");
		e.setPropertyValues(propertyValues);
		productPropertySaveModels.add(e);
		productSaveModel.setPropertyList(productPropertySaveModels);
		AddSellerProductRequest.setProduct(productSaveModel);
		return AddSellerProductRequest;
	}



	/**
	 * 初始化全球优选商品bean
	 *
	 * @param sellerId 20336378
	 * @return
	 */
	//全球优选项目发布商品20336378
	public static AddSellerProductRequest initAddSellerGlobalPspProductRequestV2(int sellerId) {
		AddSellerProductRequest AddSellerProductRequest = new AddSellerProductRequest();
		// 最外层
		AddSellerProductRequest.setSellerId(sellerId);
		String sellerName = new JUserWapper().selectUserinfoByUid(sellerId).get(0).getLoginId();
		AddSellerProductRequest.setSellerName(sellerName);
		AddSellerProductRequest.setProductSite("PC");
		// ProductSaveModel 外层
		ProductSaveModel productSaveModel = new ProductSaveModel();
		productSaveModel.setSellerId(sellerId);
		productSaveModel.setSellerLoginId(sellerName);
		productSaveModel.setProductType(0);
		productSaveModel.setProductName("测试山沟" + YMTDateUtil.getDate().getTime());
		productSaveModel.setLiveIdList(null);
		// 二级类目编号
		productSaveModel.setSecondCategoryId(1002);
		// 三级类目编号
		productSaveModel.setThirdCategoryId(1003);
		// 标准品牌编号
		productSaveModel.setBrandId(ProductManagerCallServiceV3.BrandId);
		// 标准品牌名称
		productSaveModel.setBrandName("耐克");
		// 商品图片列表
		List<String> picList = Arrays.asList("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701_400_401_n_w_l.jpg",
				"http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701_400_401.jpg",
				"http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701.jpg");
		productSaveModel.setProductPicList(picList);
		// 物流方式
		productSaveModel.setCatalogStatus(5);
		productSaveModel.setNoticeRisk(true);

		String validStart = YMTDateUtil.getBeforeOrNextDay(0, YMTDateUtil.YMDHMS);
		String validEnd = YMTDateUtil.getBeforeOrNextDay(7, YMTDateUtil.YMDHMS);
		// 商品的起始有效期
		productSaveModel.setValidStart(validStart);
		// 商品上架结束有效期
		productSaveModel.setValidEnd(validEnd);
		// 自动延期标识
		productSaveModel.setAutoRefresh(true);
		// 备货类型（0-现货，1-扫货，2- FBX）
		productSaveModel.setCatalogType(0);
		// 包税方式（交税方 0. 卖家交税，1. 买家交税,） default = 0 默认传 0
		productSaveModel.setTariffType(0);
		// 保税区
		productSaveModel.setBondedArea(7);
		// 保税商品备案号
		productSaveModel.setProductCode("Test" + YMTDateUtil.getDate());
		// 七天无理由退货
		productSaveModel.setNoReasonReturn(false);
		// 多物流方式（0-不支持，3-贝海直邮）
		productSaveModel.setMultiLogistics(0);
		// 多物流差价
		productSaveModel.setFlightBalance(0);
		productSaveModel.setWeightUnit(2);
		// 上架销售类型-1, 原时间 0, 立即上架 1, 定时上架 2, 发布但不上架 3, 按直播时间上架
		productSaveModel.setOnSaleType(0);
		// 来源
		productSaveModel.setSourceType("PC");
		// productSaveModel.setSellerCountryId();
		// 发布（true） & 编辑（false） 商品坑位计算使用，可不作为参数传入
		productSaveModel.setReleaseProduct(true);
		// 选填，长度限定为700个字符
		productSaveModel.setRemark("Testzhaxina" + YMTDateUtil.getDate());

		// 规格1
		CatalogSaveModel catalogSaveModel1 = new CatalogSaveModel();
		catalogSaveModel1.setOperateType(1);
		catalogSaveModel1.setPackage(false);
		catalogSaveModel1.setPreSale(false);
		// 规格新客价
		String newPrice = "50";
		catalogSaveModel1.setNewPrice(Integer.valueOf(newPrice));
		// 规格vip价格
		String vipPrice = "50";
		catalogSaveModel1.setVipPrice(Integer.valueOf(vipPrice));
		// 商品原价
		String price = "50";
		catalogSaveModel1.setPrice(Integer.valueOf(price));
		// BigDecimal marketPrice = new BigDecimal(20);
		String marketPrice = "50";
		catalogSaveModel1.setMarketPrice(Integer.valueOf(marketPrice));
		catalogSaveModel1.setAction(0);
		catalogSaveModel1.setStock(1000000);
		catalogSaveModel1.setMultiLogistics(0);
		catalogSaveModel1.setSku("sku-7232f1de-ffbf-49ae-a0bc-d8765456b07f");
		// 规格属性
		List<CatalogPropertySaveModel> propertyList = new ArrayList<>();
		CatalogPropertySaveModel e1 = new CatalogPropertySaveModel();
		e1.setPropertyName("颜色");
		e1.setPropertyUrl("http://s2.ymatou.com/home/b5abefb15e5afbb91d82c65df819be22.png");
		e1.setPropertyValue("红色");
		propertyList.add(e1);
		catalogSaveModel1.setPropertyList(propertyList);

		// 规格2
		CatalogSaveModel catalogSaveModel2 = new CatalogSaveModel();

		catalogSaveModel2.setOperateType(1);
		catalogSaveModel2.setPackage(false);
		catalogSaveModel2.setPreSale(false);
		// 规格新客价
		newPrice = "100";
		catalogSaveModel2.setNewPrice(Integer.valueOf(newPrice));
		// 规格vip价格
		vipPrice = "100";
		catalogSaveModel2.setVipPrice(Integer.valueOf(vipPrice));
		// 商品原价
		price = "100";
		catalogSaveModel2.setPrice(Integer.valueOf(price));
		String marketPrice1 = "100";
		catalogSaveModel2.setMarketPrice(Integer.valueOf(marketPrice1));
		catalogSaveModel2.setAction(0);
		catalogSaveModel2.setStock(1000000);
		catalogSaveModel2.setMultiLogistics(0);
		catalogSaveModel2.setSku("sku-7232f1de-ffbf-49ae-a0bc-d8765456b07f");
		// 规格属性
		List<CatalogPropertySaveModel> propertyList1 = new ArrayList<>();
		CatalogPropertySaveModel e2 = new CatalogPropertySaveModel();
		e2.setPropertyName("颜色");
		e2.setPropertyUrl("http://s2.ymatou.com/home/b5abefb15e5afbb91d82c65df819be22.png");
		e2.setPropertyValue("紫色");
		propertyList1.add(e2);
		catalogSaveModel2.setPropertyList(propertyList1);
		
		
		// 规格3
		CatalogSaveModel catalogSaveModel3 = new CatalogSaveModel();

		catalogSaveModel3.setOperateType(1);
		catalogSaveModel3.setPackage(false);
		catalogSaveModel3.setPreSale(false);
		// 规格新客价
		newPrice = "200";
		catalogSaveModel3.setNewPrice(Integer.valueOf(newPrice));
		// 规格vip价格
		vipPrice = "200";
		catalogSaveModel3.setVipPrice(Integer.valueOf(vipPrice));
		// 商品原价
		price = "200";
		catalogSaveModel3.setPrice(Integer.valueOf(price));
		String marketPrice3 = "200";
		catalogSaveModel3.setMarketPrice(Integer.valueOf(marketPrice3));
		catalogSaveModel3.setAction(0);
		catalogSaveModel3.setStock(1000000);
		catalogSaveModel3.setMultiLogistics(0);
		catalogSaveModel3.setSku("sku-7232f1de-ffbf-49ae-a0bc-d8765456b07f");
		// 规格属性
		List<CatalogPropertySaveModel> propertyList2 = new ArrayList<>();
		CatalogPropertySaveModel e3 = new CatalogPropertySaveModel();
		e3.setPropertyName("颜色");
		e3.setPropertyUrl("http://s2.ymatou.com/home/b5abefb15e5afbb91d82c65df819be22.png");
		e3.setPropertyValue("蓝色");
		propertyList2.add(e3);
		catalogSaveModel3.setPropertyList(propertyList2);

		List<CatalogSaveModel> catalogSaveModels = new ArrayList<>();
		catalogSaveModels.add(catalogSaveModel1);
		catalogSaveModels.add(catalogSaveModel2);
		catalogSaveModels.add(catalogSaveModel3);
		productSaveModel.setCatalogList(catalogSaveModels);

		// 商品文描
		ProductDescSaveModel descModel = new ProductDescSaveModel();
		descModel.setDescription("商品文描");
		List<String> descPicList = new ArrayList<>();
		descPicList.add("http://s2.ymatou.com/home/4aa0780b5ffeee46a01f132052fdb71a.png");
		descPicList.add("http://s2.ymatou.com/home/4aa0780b5ffeee46a01f132052fdb71b.png");
		descPicList.add("http://s2.ymatou.com/home/4aa0780b5ffeee46a01f132052fdb71c.png");
		descPicList.add("http://s2.ymatou.com/home/4aa0780b5ffeee46a01f132052fdb71d.png");
		descPicList.add("http://s2.ymatou.com/home/4aa0780b5ffeee46a01f132052fdb71e.png");
		descModel.setDescPicList(descPicList);
		descModel.setBuyerNoticeId(0);
		descModel.setDeclarationId(0);
		descModel.setSellerServiceId(0);
		descModel.setSizeTemplateId(0);
		productSaveModel.setDescModel(descModel);

		// 商品关联运费模板
		List<ProductFreightSaveModel> freightTemplateList = new ArrayList<>();
		productSaveModel.setFreightTemplateList(freightTemplateList);

		// 商品视频 null
		productSaveModel.setVideoModel(null);

		// 商品属性
		List<ProductPropertySaveModel> productPropertySaveModels = new ArrayList<>();
		ProductPropertySaveModel e = new ProductPropertySaveModel();
		e.setPropertyId(1);
		List<String> propertyValues = new ArrayList<>();
		propertyValues.add("propertyValue1");
		propertyValues.add("propertyValue2");
		e.setPropertyValues(propertyValues);
		productPropertySaveModels.add(e);
		productSaveModel.setPropertyList(productPropertySaveModels);
		AddSellerProductRequest.setProduct(productSaveModel);
		return AddSellerProductRequest;
	}
	
	
	/**
	 * 初始化商品库商品
	 *
	 * @param sellerId 20336378
	 * @return
	 * @throws Exception
	 */
	public static AddSellerProductRequest initAddSellerSpuProduct(int sellerId) throws Exception {
		List<Map> SpuProduct = new YmtProductsIWapper().GetSpuProductBySellerId(sellerId, 229);
		System.out.println(SpuProduct);
		SpuProduct.forEach(b->{
			Logger.comment("删除老spu商品"+b.get("sProductId").toString());
			new YmtProductsIWapper().DeleteSpuProductByProductId(b.get("sProductId").toString());
		});
		AddSellerProductRequest AddSellerProductRequest = new AddSellerProductRequest();
		// 最外层
		AddSellerProductRequest.setSellerId(sellerId);
		String sellerName = new JUserWapper().selectUserinfoByUid(sellerId).get(0).getLoginId();
		AddSellerProductRequest.setSellerName(sellerName);
		AddSellerProductRequest.setProductSite("PC");
		// ProductSaveModel 外层
		ProductSaveModel productSaveModel = new ProductSaveModel();
		//商品库
		productSaveModel.setSpuId(229);
		productSaveModel.setSpuProductId(229);
		
		productSaveModel.setSellerId(sellerId);
		productSaveModel.setSellerLoginId(sellerName);
		productSaveModel.setProductType(0);
		productSaveModel.setProductName("测试山沟" + YMTDateUtil.getDate().getTime());
		productSaveModel.setLiveIdList(null);
		// 二级类目编号
		productSaveModel.setSecondCategoryId(1087);
		// 三级类目编号
		productSaveModel.setThirdCategoryId(1096);
		// 标准品牌编号
		productSaveModel.setBrandId(13540);
		// 标准品牌名称
		productSaveModel.setBrandName("SK-II");
		// 商品图片列表
		List<String> picList = Arrays.asList("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701_400_401_n_w_l.jpg",
				"http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701_400_401.jpg",
				"http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701.jpg");
		productSaveModel.setProductPicList(picList);
		// 物流方式
		productSaveModel.setCatalogStatus(5);
		productSaveModel.setNoticeRisk(true);

		String validStart = YMTDateUtil.getBeforeOrNextDay(0, YMTDateUtil.YMDHMS);
		String validEnd = YMTDateUtil.getBeforeOrNextDay(7, YMTDateUtil.YMDHMS);
		// 商品的起始有效期
		productSaveModel.setValidStart(validStart);
		// 商品上架结束有效期
		productSaveModel.setValidEnd(validEnd);
		// 自动延期标识
		productSaveModel.setAutoRefresh(true);
		// 备货类型（0-现货，1-扫货，2- FBX）
		productSaveModel.setCatalogType(0);
		// 包税方式（交税方 0. 卖家交税，1. 买家交税,） default = 0 默认传 0
		productSaveModel.setTariffType(0);
		// 保税区
		productSaveModel.setBondedArea(7);
		// 保税商品备案号
		productSaveModel.setProductCode("Test" + YMTDateUtil.getDate());
		// 七天无理由退货
		productSaveModel.setNoReasonReturn(false);
		// 多物流方式（0-不支持，3-贝海直邮）
		productSaveModel.setMultiLogistics(0);
		// 多物流差价
		productSaveModel.setFlightBalance(0);
		productSaveModel.setWeightUnit(2);
		// 上架销售类型-1, 原时间 0, 立即上架 1, 定时上架 2, 发布但不上架 3, 按直播时间上架
		productSaveModel.setOnSaleType(0);
		// 来源
		productSaveModel.setSourceType("PC");
		// productSaveModel.setSellerCountryId();
		// 发布（true） & 编辑（false） 商品坑位计算使用，可不作为参数传入
		productSaveModel.setReleaseProduct(true);
		// 选填，长度限定为700个字符
		productSaveModel.setRemark("Testzhaxina" + YMTDateUtil.getDate());

		List<ProductPropertySaveModel> Propertys = new ArrayList<ProductPropertySaveModel>();
		Propertys.add(new ProductPropertySaveModel(9, Arrays.asList("加拿大")));
		Propertys.add(new ProductPropertySaveModel(26, Arrays.asList("小样")));
		Propertys.add(new ProductPropertySaveModel(82, Arrays.asList("否")));
		
		productSaveModel.setPropertyList(Propertys);
		//新增 wuwen 20210113
		productSaveModel.setDeliveryAging(0);
		// 规格1
		CatalogSaveModel catalogSaveModel1 = new CatalogSaveModel();
		catalogSaveModel1.setSpuCatalogId(1250);
		catalogSaveModel1.setOperateType(1);
		catalogSaveModel1.setPackage(false);
		catalogSaveModel1.setPreSale(false);
		// 规格新客价
		String newPrice = "8";
		catalogSaveModel1.setNewPrice(Integer.valueOf(newPrice));
		// 规格vip价格
		String vipPrice = "12";
		catalogSaveModel1.setVipPrice(Integer.valueOf(vipPrice));
		// 商品原价
		String price = "16";
		catalogSaveModel1.setPrice(Integer.valueOf(price));
		// BigDecimal marketPrice = new BigDecimal(20);
		String marketPrice = "20";
		catalogSaveModel1.setMarketPrice(Integer.valueOf(marketPrice));
		catalogSaveModel1.setAction(0);
		catalogSaveModel1.setStock(1000000);
		catalogSaveModel1.setMultiLogistics(0);
//		catalogSaveModel1.setSku("sku-7232f1de-ffbf-49ae-a0bc-d8765456b07f");
		// 规格属性
		List<CatalogPropertySaveModel> propertyList = new ArrayList<>();
		CatalogPropertySaveModel e1 = new CatalogPropertySaveModel();
		e1.setPropertyName("颜色分类");
		e1.setPropertyUrl("http://s2.ymatou.com/home/b5abefb15e5afbb91d82c65df819be22.png");
		e1.setPropertyValue("绿色");
		propertyList.add(e1);
		catalogSaveModel1.setPropertyList(propertyList);
		
		// 规格2
		CatalogSaveModel catalogSaveModel2 = new CatalogSaveModel();

		catalogSaveModel2.setSpuCatalogId(1249);
		catalogSaveModel2.setOperateType(1);
		catalogSaveModel2.setPackage(false);
		catalogSaveModel2.setPreSale(false);
		// 规格新客价
		newPrice = "10";
		catalogSaveModel2.setNewPrice(Integer.valueOf(newPrice));
		// 规格vip价格
		vipPrice = "15";
		catalogSaveModel2.setVipPrice(Integer.valueOf(vipPrice));
		// 商品原价
		price = "20";
		catalogSaveModel2.setPrice(Integer.valueOf(price));
		String marketPrice1 = "30";
		catalogSaveModel2.setMarketPrice(Integer.valueOf(marketPrice1));
		catalogSaveModel2.setAction(0);
		catalogSaveModel2.setStock(1000000);
		catalogSaveModel2.setMultiLogistics(0);
//		catalogSaveModel2.setSku("sku-31212312");
		// 规格属性
		List<CatalogPropertySaveModel> propertyList1 = new ArrayList<>();
		CatalogPropertySaveModel e2 = new CatalogPropertySaveModel();
		e2.setPropertyName("颜色分类");
		e2.setPropertyUrl("http://s2.ymatou.com/home/b5abefb15e5afbb91d82c65df819be22.png");
		e2.setPropertyValue("红色");
		propertyList1.add(e2);
		catalogSaveModel2.setPropertyList(propertyList1);

		List<CatalogSaveModel> catalogSaveModels = new ArrayList<>();
		catalogSaveModels.add(catalogSaveModel1);
		catalogSaveModels.add(catalogSaveModel2);
		productSaveModel.setCatalogList(catalogSaveModels);

		// 商品文描
		ProductDescSaveModel descModel = new ProductDescSaveModel();
		descModel.setDescription("商品文描");
		List<String> descPicList = new ArrayList<>();
		descPicList.add("http://s2.ymatou.com/home/4aa0780b5ffeee46a01f132052fdb71a.png");
		descPicList.add("http://s2.ymatou.com/home/4aa0780b5ffeee46a01f132052fdb71b.png");
		descPicList.add("http://s2.ymatou.com/home/4aa0780b5ffeee46a01f132052fdb71c.png");
		descPicList.add("http://s2.ymatou.com/home/4aa0780b5ffeee46a01f132052fdb71d.png");
		descPicList.add("http://s2.ymatou.com/home/4aa0780b5ffeee46a01f132052fdb71e.png");
		descModel.setDescPicList(descPicList);
		descModel.setBuyerNoticeId(0);
		descModel.setDeclarationId(0);
		descModel.setSellerServiceId(0);
		descModel.setSizeTemplateId(0);
		productSaveModel.setDescModel(descModel);

		// 商品关联运费模板
		List<ProductFreightSaveModel> freightTemplateList = new ArrayList<>();
		productSaveModel.setFreightTemplateList(freightTemplateList);

		// 商品视频 null
		productSaveModel.setVideoModel(null);

		AddSellerProductRequest.setProduct(productSaveModel);
		return AddSellerProductRequest;

	}
	/**
	 * 初始化全球优选商品bean
	 *
	 * @param sellerId 20336378
	 * @return
	 */
	//全球优选项目发布商品20336378
	public static AddSellerProductRequest initAddSellerGlobalPspProductRequest(int sellerId) {
		AddSellerProductRequest AddSellerProductRequest = new AddSellerProductRequest();
		// 最外层
		AddSellerProductRequest.setSellerId(sellerId);
		String sellerName = new JUserWapper().selectUserinfoByUid(sellerId).get(0).getLoginId();
		AddSellerProductRequest.setSellerName(sellerName);
		AddSellerProductRequest.setProductSite("PC");
		// ProductSaveModel 外层
		ProductSaveModel productSaveModel = new ProductSaveModel();
		productSaveModel.setSellerId(sellerId);
		productSaveModel.setSellerLoginId(sellerName);
		productSaveModel.setProductType(0);
		productSaveModel.setProductName("测试山沟" + YMTDateUtil.getDate().getTime());
		productSaveModel.setLiveIdList(null);
		// 二级类目编号
		productSaveModel.setSecondCategoryId(1002);
		// 三级类目编号
		productSaveModel.setThirdCategoryId(1003);
		// 标准品牌编号
		productSaveModel.setBrandId(ProductManagerCallServiceV3.BrandId);
		// 标准品牌名称
		productSaveModel.setBrandName("耐克");
		// 商品图片列表
		List<String> picList = Arrays.asList("http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701_400_401_n_w_l.jpg",
				"http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701_400_401.jpg",
				"http://pc1.img.ymatou.com/G01/shangou/M00/2C/D0/rBBlD1gHOV6AY32AAAEN6UG5TOc701.jpg");
		productSaveModel.setProductPicList(picList);
		// 物流方式
		//productSaveModel.setCatalogStatus(5);
		productSaveModel.setCatalogStatus(4);
		productSaveModel.setNoticeRisk(true);

		String validStart = YMTDateUtil.getBeforeOrNextDay(0, YMTDateUtil.YMDHMS);
		String validEnd = YMTDateUtil.getBeforeOrNextDay(7, YMTDateUtil.YMDHMS);
		// 商品的起始有效期
		productSaveModel.setValidStart(validStart);
		// 商品上架结束有效期
		productSaveModel.setValidEnd(validEnd);
		// 自动延期标识
		productSaveModel.setAutoRefresh(true);
		// 备货类型（0-现货，1-扫货，2- FBX）
		productSaveModel.setCatalogType(0);
		// 包税方式（交税方 0. 卖家交税，1. 买家交税,） default = 0 默认传 0
		productSaveModel.setTariffType(0);
		// 保税区
		productSaveModel.setBondedArea(7);
		// 保税商品备案号
		productSaveModel.setProductCode("Test" + YMTDateUtil.getDate());
		// 七天无理由退货
		productSaveModel.setNoReasonReturn(false);
		// 多物流方式（0-不支持，3-贝海直邮）
		productSaveModel.setMultiLogistics(0);
		// 多物流差价
		productSaveModel.setFlightBalance(0);
		productSaveModel.setWeightUnit(2);
		// 上架销售类型-1, 原时间 0, 立即上架 1, 定时上架 2, 发布但不上架 3, 按直播时间上架
		productSaveModel.setOnSaleType(0);
		// 来源
		productSaveModel.setSourceType("PC");
		// productSaveModel.setSellerCountryId();
		// 发布（true） & 编辑（false） 商品坑位计算使用，可不作为参数传入
		productSaveModel.setReleaseProduct(true);
		// 选填，长度限定为700个字符
		productSaveModel.setRemark("Testzhaxina" + YMTDateUtil.getDate());

		// 规格1
		CatalogSaveModel catalogSaveModel1 = new CatalogSaveModel();
		catalogSaveModel1.setOperateType(1);
		catalogSaveModel1.setPackage(false);
		catalogSaveModel1.setPreSale(false);
		// 规格新客价
		String newPrice = "8";
		catalogSaveModel1.setNewPrice(Integer.valueOf(newPrice));
		// 规格vip价格
		String vipPrice = "12";
		catalogSaveModel1.setVipPrice(Integer.valueOf(vipPrice));
		// 商品原价
		String price = "16";
		catalogSaveModel1.setPrice(Integer.valueOf(price));
		// BigDecimal marketPrice = new BigDecimal(20);
		String marketPrice = "20";
		catalogSaveModel1.setMarketPrice(Integer.valueOf(marketPrice));
		catalogSaveModel1.setAction(0);
		catalogSaveModel1.setStock(1000000);
		catalogSaveModel1.setMultiLogistics(0);
		catalogSaveModel1.setSku("sku-7232f1de-ffbf-49ae-a0bc-d8765456b07f");
		// 规格属性
		List<CatalogPropertySaveModel> propertyList = new ArrayList<>();
		CatalogPropertySaveModel e1 = new CatalogPropertySaveModel();
		e1.setPropertyName("颜色");
		e1.setPropertyUrl("http://s2.ymatou.com/home/b5abefb15e5afbb91d82c65df819be22.png");
		e1.setPropertyValue("红色");
		propertyList.add(e1);
		catalogSaveModel1.setPropertyList(propertyList);

		// 规格2
		CatalogSaveModel catalogSaveModel2 = new CatalogSaveModel();

		catalogSaveModel2.setOperateType(1);
		catalogSaveModel2.setPackage(false);
		catalogSaveModel2.setPreSale(false);
		// 规格新客价
		newPrice = "10";
		catalogSaveModel2.setNewPrice(Integer.valueOf(newPrice));
		// 规格vip价格
		vipPrice = "15";
		catalogSaveModel2.setVipPrice(Integer.valueOf(vipPrice));
		// 商品原价
		price = "20";
		catalogSaveModel2.setPrice(Integer.valueOf(price));
		String marketPrice1 = "30";
		catalogSaveModel2.setMarketPrice(Integer.valueOf(marketPrice1));
		catalogSaveModel2.setAction(0);
		catalogSaveModel2.setStock(1000000);
		catalogSaveModel2.setMultiLogistics(0);
		catalogSaveModel2.setSku("sku-7232f1de-ffbf-49ae-a0bc-d8765456b07f");
		// 规格属性
		List<CatalogPropertySaveModel> propertyList1 = new ArrayList<>();
		CatalogPropertySaveModel e2 = new CatalogPropertySaveModel();
		e2.setPropertyName("颜色");
		e2.setPropertyUrl("http://s2.ymatou.com/home/b5abefb15e5afbb91d82c65df819be22.png");
		e2.setPropertyValue("蓝色");
		propertyList1.add(e2);
		catalogSaveModel2.setPropertyList(propertyList1);

		List<CatalogSaveModel> catalogSaveModels = new ArrayList<>();
		catalogSaveModels.add(catalogSaveModel1);
		catalogSaveModels.add(catalogSaveModel2);
		productSaveModel.setCatalogList(catalogSaveModels);

		// 商品文描
		ProductDescSaveModel descModel = new ProductDescSaveModel();
		descModel.setDescription("商品文描");
		List<String> descPicList = new ArrayList<>();
		descPicList.add("http://s2.ymatou.com/home/4aa0780b5ffeee46a01f132052fdb71a.png");
		descPicList.add("http://s2.ymatou.com/home/4aa0780b5ffeee46a01f132052fdb71b.png");
		descPicList.add("http://s2.ymatou.com/home/4aa0780b5ffeee46a01f132052fdb71c.png");
		descPicList.add("http://s2.ymatou.com/home/4aa0780b5ffeee46a01f132052fdb71d.png");
		descPicList.add("http://s2.ymatou.com/home/4aa0780b5ffeee46a01f132052fdb71e.png");
		descModel.setDescPicList(descPicList);
		descModel.setBuyerNoticeId(0);
		descModel.setDeclarationId(0);
		descModel.setSellerServiceId(0);
		descModel.setSizeTemplateId(0);
		productSaveModel.setDescModel(descModel);

		// 商品关联运费模板
		List<ProductFreightSaveModel> freightTemplateList = new ArrayList<>();
		productSaveModel.setFreightTemplateList(freightTemplateList);

		// 商品视频 null
		productSaveModel.setVideoModel(null);

		// 商品属性
		List<ProductPropertySaveModel> productPropertySaveModels = new ArrayList<>();
		ProductPropertySaveModel e = new ProductPropertySaveModel();
		e.setPropertyId(1);
		List<String> propertyValues = new ArrayList<>();
		propertyValues.add("propertyValue1");
		propertyValues.add("propertyValue2");
		e.setPropertyValues(propertyValues);
		productPropertySaveModels.add(e);
		productSaveModel.setPropertyList(productPropertySaveModels);
		AddSellerProductRequest.setProduct(productSaveModel);
		return AddSellerProductRequest;
	}

	/**
	 * 全球优选 升级礼包类型
	 * giftType 礼包类型1礼包商品，2优选团商品
	 * @throws Exception
	 */
	//发布商品,升级礼包类型
	public static void AddSellerGlobalPspProduct(int sellerId,String productId,int giftType) throws Exception{
        UpdateGiftTypeBean updategifttypeBean = new UpdateGiftTypeBean();
        updategifttypeBean.setProductId(productId);
        updategifttypeBean.setUserId(sellerId);
		updategifttypeBean.setGiftType(giftType);
        UpdateGiftTypeCall updategifttypeCall = new UpdateGiftTypeCall();
        updategifttypeCall.setData(updategifttypeBean);
        updategifttypeCall.callService();
    }

    /**
	 * 批量修改优选商品销售佣金
	 * 规格级别
	 */
    public static void UpdateCatalogCommisions(Integer sellerId, String productId, String catalogId, String sellerName, BigDecimal saleCommission) throws Exception{
    	UpdateCatalogCommisionsBean updateCatalogCommisionsBean = new UpdateCatalogCommisionsBean();
    	UpdateCatalogCommisionsCall updateCatalogCommisionsCall = new UpdateCatalogCommisionsCall();
		updateCatalogCommisionsBean.setUserId(sellerId);
		updateCatalogCommisionsBean.setSellerName(sellerName);
		updateCatalogCommisionsBean.setProductId(productId);

		SaleCommissionDto saleCommissionDto = new SaleCommissionDto();
		saleCommissionDto.setSaleCommission(saleCommission);
		saleCommissionDto.setCatalogId(catalogId);

		updateCatalogCommisionsBean.setCommissionList(Arrays.asList(saleCommissionDto));
		updateCatalogCommisionsCall.setData(updateCatalogCommisionsBean);
		updateCatalogCommisionsCall.callService();
	}

	/**
	 * 修改优选团商品佣金价格
	 * @param sellerId
	 * @param productId
	 * @param catalogId
	 * @param sellerName
	 * @param saleCommissionList
	 * @throws Exception
	 */
	public static void UpdateCatalogCommisionsV2(Integer sellerId, String productId, String catalogId, String sellerName,List<BigDecimal> saleCommissionList) throws Exception{
		UpdateCatalogCommisionsBean updateCatalogCommisionsBean = new UpdateCatalogCommisionsBean();
		UpdateCatalogCommisionsCall updateCatalogCommisionsCall = new UpdateCatalogCommisionsCall();
		updateCatalogCommisionsBean.setUserId(sellerId);
		updateCatalogCommisionsBean.setSellerName(sellerName);
		updateCatalogCommisionsBean.setProductId(productId);

		SaleCommissionDto saleCommissionDto = new SaleCommissionDto();
		saleCommissionDto.setSaleCommissionList(saleCommissionList);
		saleCommissionDto.setSaleCommission(saleCommissionList.get(0));
		saleCommissionDto.setCatalogId(catalogId);

		updateCatalogCommisionsBean.setCommissionList(Arrays.asList(saleCommissionDto));
		updateCatalogCommisionsCall.setData(updateCatalogCommisionsBean);
		updateCatalogCommisionsCall.callService();
}

	/**
	 * 修改优选团商品佣金价格
	 * @param sellerId
	 * @param productId
	 * @param catalogId
	 * @param sellerName
	 * @param saleCommissions
	 * @throws Exception
	 */
	public static void UpdateCatalogCommisionsV3(Integer sellerId, String productId, String catalogId, String sellerName,BigDecimal saleCommissions) throws Exception{
		UpdateCatalogCommisionsBean updateCatalogCommisionsBean = new UpdateCatalogCommisionsBean();
		UpdateCatalogCommisionsCall updateCatalogCommisionsCall = new UpdateCatalogCommisionsCall();
		updateCatalogCommisionsBean.setUserId(sellerId);
		updateCatalogCommisionsBean.setSellerName(sellerName);
		updateCatalogCommisionsBean.setProductId(productId);

		SaleCommissionDto saleCommissionDto = new SaleCommissionDto();
		saleCommissionDto.setSaleCommission(saleCommissions);
		saleCommissionDto.setCatalogId(catalogId);

		updateCatalogCommisionsBean.setCommissionList(Arrays.asList(saleCommissionDto));
		updateCatalogCommisionsCall.setData(updateCatalogCommisionsBean);
		updateCatalogCommisionsCall.callService();
}

	/**
	 * 批量修改平台佣金
	 * @
	 */
	public static void UpdateProductCommision(int sellerId,String productId,String sellerName,BigDecimal commission) throws IOException {
		UpdateProductCommisionBean updateProductCommisionBean = new UpdateProductCommisionBean();
		UpdateProductCommisionCall updateProductCommisionCall = new UpdateProductCommisionCall();
		updateProductCommisionBean.setCommission(commission);
		updateProductCommisionBean.setSellerName(sellerName);
		updateProductCommisionBean.setProductId(productId);
		updateProductCommisionBean.setUserId(sellerId);
		updateProductCommisionCall.setData(updateProductCommisionBean);
		updateProductCommisionCall.callService();
	}
	/**
	 * 创建商品
	 * 
	 * @param addsellerproduct
	 * @return
	 * @throws Exception
	 */
	public static JsonObject addNewProduct(AddSellerProductRequest addsellerproduct) throws Exception {
		AddSellerProductCall addSellerProductCall = new AddSellerProductCall();
		addSellerProductCall.setData(false, addsellerproduct);
		addSellerProductCall.addHeader("mock", "mock-enable");
		addSellerProductCall.addHeader("mockId-1", TestDataManager.getRandomUUID().toString());
		addSellerProductCall.addHeader("mockApi-1", "orderdelivery-GetAvailableDeliveryMethod-Normal");
		try {
			addSellerProductCall.callService();
		}catch (Exception e) {
			// TODO: handle exception
		}
		int redo=0;
		while (!"200".equals(addSellerProductCall.getString("Code"))&&redo<3) {
			Thread.sleep(5000);
			addSellerProductCall.callService();
			redo++;
		}
		return addSellerProductCall.getJsonObject();
	}

	public static JsonObject addNewProductV2(AddSellerProductRequest addsellerproduct) throws Exception {
		AddSellerProductCall addSellerProductCall = new AddSellerProductCall();
		addSellerProductCall.setData(addsellerproduct);
		addSellerProductCall.callService();

		return addSellerProductCall.getJsonObject();
	}
	/**
	 * 找出一个sellerid下对应的vip用户的uid 没找到的话返回null
	 * @param sellerid
	 * @return
	 */
	public static Integer getVipUid(Integer sellerid){
		Long uid=null;
		try{
			uid=new UserAnalysisMongoWapper().findVipBySellerid(Long.valueOf(sellerid)).get(0).getUserId();
		}catch (Exception e) {
			e.printStackTrace();
		}
		return uid.intValue();
	}
	/**
	 * 强制下架
	 * 
	 * @throws ClientProtocolException
	 * @throws IOException
	 */
	public static void UpdateToOffSale(int sellerId, String productId) throws ClientProtocolException, IOException {
		UpdateProductCheckStatusCall UpdateProductCheckStatusCall = new UpdateProductCheckStatusCall();
		UpdateProductCheckStatusRequest bean = new UpdateProductCheckStatusRequest();
		bean.setCheckStatus(-1);
		bean.setOperator("autotest");
		List<CheckStatusDto> productList = new ArrayList<>();
		CheckStatusDto e = new CheckStatusDto();
		e.setSellerId(sellerId);
		e.setProductId(productId);
		productList.add(e);
		bean.setProductList(productList);
		UpdateProductCheckStatusCall.setData(false, bean);
		UpdateProductCheckStatusCall.callService();
	}

	// 以下快捷方法用于做商品数据前置条件
	/**
	 * 修改商家发布商品限制数量
	 */
	public static void updateSellerPublishLimit(Integer pits, Integer sellerid) {
		new YmtSellerReportWapper().updateSellerPublishLimit(pits, sellerid);
	}

	/**
	 * 创建一个交易隔离活动
	 * 
	 * @return activeid
	 * @throws JSONException
	 */
	public static Integer createIsolationActivityInProcess() throws JSONException {
		return ActivityCallService.createIsolationActivityInProcess();
	}

	/**
	 * 创建一个预售活动
	 * @return
	 * @throws JSONException
	 */
	public static Integer createIsolationAdvanceActivityInProcess() throws JSONException {
		return ActivityCallService.createIsolationAdvanceActivityInProcess();
	}

	/**
	 * 创建一个非交易隔离活动
	 * 
	 * @return activeid
	 * @throws JSONException
	 */
	public static Integer createNoIsolationActivityInProcess() throws JSONException {
		return ActivityCallService.createNoIsolationActivityInProcess();
	}

	
	/**
	 * 创建一个神器折扣活动
	 * 
	 * @return activeid
	 * @throws JSONException
	 */
	public static Integer createGodDiscount() throws JSONException {
		return ActivityCallService.createGodDiscount();
	}
	public static Integer createNoIsolationActivityInProcessV2() throws JSONException {
		return ActivityCallService.createNoIsolationActivityInProcessV2();
	}

	/**
	 * 创建一个非交易隔离的低优先级活动
	 * @return
	 * @throws JSONException
	 */
	public static Integer createNoIsolationAndLowActivityInProcess() throws JSONException {
		return ActivityCallService.createNoIsolationAndLowActivityInProcess();
	}
	/**
	 *
	 * @return创建 低优先级活动
	 * @throws JSONException
	 */
	public static Integer createLowActivityInProcess() throws JSONException {
		return ActivityCallService.createLowActivityInProcess();
	}

	/**
	 * 报名审核活动
	 * 
	 * @param productId
	 *            商品id
	 * @param sellerId
	 *            商家id
	 * @param catalogList
	 *            规格列表
	 * @param activityId
	 *            活动id
	 * @param ActivityStockNum
	 *            活动库存
	 * @throws Exception
	 */
	public static void addActivity(String productId, Integer sellerId, List<String> catalogList, String activityId, Integer ActivityStockNum) throws Exception {
		List<Map> mpids = new ArrayList<>();
		Map map = new HashMap<>();
		map.put("productId", productId);
		map.put("catalogList", catalogList);
		map.put("sellerId", sellerId);
		map.put("sellerName", new JUserWapper().selectUserinfoByUid(sellerId).get(0).getLoginId());
		map.put("activityId", activityId);
		map.put("ActivityStockNum", ActivityStockNum);
		mpids.add(map);
		addActivity(mpids);
	}

	/**
	 * 报名审核活动 通用 List<productId sellerId sellerName catalogList> activityId
	 * ActivityStockNum
	 * 
	 * @throws Exception
	 */
	public static void addActivity(List<Map> mpids) throws Exception {
		Logger.debug("报名活动");
		for (Map map : mpids) {
			String productId = map.get("productId").toString();
			Integer sellerId = Integer.valueOf(map.get("sellerId").toString());
			String sellerName = map.get("sellerName").toString();
			List<String> catalogList = (List<String>) map.get("catalogList");
			String activityId2 = map.get("activityId").toString();
			// 默认1个活动库存
			Integer ActivityStockNum = map.get("ActivityStockNum") == null ? 1 : Integer.valueOf(map.get("ActivityStockNum").toString());
			ApplyActivityCall activityCall = new ApplyActivityCall();
			JSONObject applyEffectiveActBean = activityCall.getJsonBean(null);
			String applyMsg = "";
			Map<String, Object> requestMap = new HashMap<String, Object>();
			requestMap.put("SellerId", sellerId);
			if (activityId2 == null || activityId2.length() == 0) {
				requestMap.put("ActivityId", activityId);
			} else {
				requestMap.put("ActivityId", activityId2);
			}
			requestMap.put("ActivityProducts[0]->ProductId", productId);

			for (int i = 0; i < catalogList.size(); i++) {
				JSONArray CatalogListBean = applyEffectiveActBean.getJSONArray("ActivityProducts").getJSONObject(0).getJSONArray("ApplyCatalogs");
				CatalogListBean.put(i, new JSONObject(CatalogListBean.get(0).toString()));
				CatalogListBean.getJSONObject(i).put("CatalogId", catalogList.get(i));
				CatalogListBean.getJSONObject(i).put("ActivityStockNum", ActivityStockNum);
				CatalogListBean.getJSONObject(i).put("ActivityPrice", price);
				CatalogListBean.getJSONObject(i).put("Sku", "");
				CatalogListBean.getJSONObject(i).put("BkcKey", "");
				CatalogListBean.getJSONObject(i).put("ProductInActivityId", 0);
			}

			JsonBeanHelper.updateJsonBean(applyEffectiveActBean, requestMap);

			activityCall.setData(applyEffectiveActBean);
			Logger.debug("报名");
			activityCall.callService();
			JSONObject ret = new JSONObject(activityCall.getReturnData());
			applyMsg = activityCall.getReturnData();
			if (ret.has("Data") && ret.getJSONObject("Data").has("ApplySuccessProducts") && ret.getJSONObject("Data").getJSONArray("ApplySuccessProducts").length() > 0) {
				JSONArray aslist = ret.getJSONObject("Data").getJSONArray("ApplySuccessProducts");
				for (int i = 0; i < aslist.length(); i++) {
					String inaid = aslist.getJSONObject(i).getString("ProductInActivityId");
					AdminCallService.approveProductInActivity(adminuser, adminpwd, inaid,
							MapUtil.hashMap("productBeginTime", YMTDateUtil.getBeforeOrNextSecond(300), "productEndTime", YMTDateUtil.getBeforeOrNextSecond(10 * 60 * 60 * 24)));
					String msgSuccess = "product: " + productId + ",inaid:" + inaid;
					Logger.debug("审核:" + msgSuccess);
				}
			}
		}

	}

	/**
	 * 报名活动
	 * 
	 * @param productId 报名活动商品id
	 * @param sellerId 报名活动商家id
	 * @param catalogList 报名活动规格列表
	 * @param activityId2 报名活动id
	 * @param ActivityStockNum 活动规格库存
	 * @return List<String> inaids 返回商品活动id ProductInActivityId
	 * @throws Exception
	 */
	public static List<String> ApplyActivity(String productId, Integer sellerId, List<String> catalogList, Integer activityId2, Integer ActivityStockNum,String aprice) throws Exception {
		Logger.debug("报名活动");
		List<String> inaids = new ArrayList<>();
		String sellerName = new JUserWapper().selectUserinfoByUid(sellerId).get(0).getLoginId();
		// 默认1个活动库存
		ApplyActivityCall activityCall = new ApplyActivityCall();
		JSONObject applyEffectiveActBean = activityCall.getJsonBean(null);
		String applyMsg = "";
		Map<String, Object> requestMap = new HashMap<String, Object>();
		requestMap.put("SellerId", sellerId);
		requestMap.put("ActivityId", activityId2);
		requestMap.put("ActivityProducts[0]->ProductId", productId);
        applyEffectiveActBean.getJSONArray("ActivityProducts").getJSONObject(0).put("ProductNameInActivity","1111111");
		for (int i = 0; i < catalogList.size(); i++) {
			JSONArray CatalogListBean = applyEffectiveActBean.getJSONArray("ActivityProducts").getJSONObject(0).getJSONArray("ApplyCatalogs");
			CatalogListBean.put(i, new JSONObject(CatalogListBean.get(0).toString()));
			CatalogListBean.getJSONObject(i).put("CatalogId", catalogList.get(i));
			CatalogListBean.getJSONObject(i).put("ActivityStockNum", ActivityStockNum);
			if(aprice!=null&&aprice.length()>0){
				CatalogListBean.getJSONObject(i).put("ActivityPrice", aprice);
			}else{
				CatalogListBean.getJSONObject(i).put("ActivityPrice", price);
			}
			CatalogListBean.getJSONObject(i).put("Sku", "");
			CatalogListBean.getJSONObject(i).put("BkcKey", "");
			CatalogListBean.getJSONObject(i).put("ProductInActivityId", 0);
		}
		JsonBeanHelper.updateJsonBean(applyEffectiveActBean, requestMap);
		activityCall.setData(applyEffectiveActBean);
		Logger.debug("报名");
		activityCall.callService();
		try {
			JSONObject ret = new JSONObject(activityCall.getReturnData());
			JSONArray aslist = ret.getJSONObject("Data").getJSONArray("ApplySuccessProducts");
			for (int i = 0; i < aslist.length(); i++) {
				String inaid = aslist.getJSONObject(i).get("ProductInActivityId").toString();
				inaids.add(inaid);
			}
		} catch (Exception e) {
			Logger.comment("报名活动失败：" + e.getMessage());

		}
		return inaids;

	}

	/**
	 * 审核活动商品
	 * @param inaid 商品活动id ProductInActivityId
	 * @param effectnow 是否立刻生效 默认5分钟后生效活动价格(productBeginTime)
	 * @throws Exception
	 */
	public static void approveProductInActivity(String productId,String inaid,boolean effectnow) throws Exception{
		Logger.comment("审核活动商品ProductInActivityId:"+inaid);
		AdminCallService.approveProductInActivity(adminuser, adminpwd, inaid,
//				MapUtil.hashMap("productBeginTime", YMTDateUtil.getBeforeOrNextSecond(5), "productEndTime", YMTDateUtil.getBeforeOrNextSecond(10 * 60 * 60 * 24)));
				MapUtil.hashMap("productBeginTime", YMTDateUtil.getBeforeOrNextSecond(5*60), "productEndTime", YMTDateUtil.getBeforeOrNextHour(3)));
		Thread.sleep(2000);
		if(effectnow){
			//修改库存时间
			new YmtProductActivityStockWapper().updateStartTimeByProductId(productId, YMTDateUtil.getBeforeOrNextSecond(-300, YMTDateUtil.YMDHMS));
			//修改活动时间
			new ActivityProductsWapper().updateStartTimeByInAid(Integer.valueOf(inaid), YMTDateUtil.getBeforeOrNextDate(-1));
		}
		//updateProductTimeStamp(productId);
	}

	public static void approveProductInActivityV2(String productId,String inaid,boolean effectnow) throws Exception{
		Logger.comment("审核活动商品ProductInActivityId:"+inaid);
		AdminCallService.approveProductInActivity(adminuser, adminpwd, inaid,
				MapUtil.hashMap("productBeginTime", YMTDateUtil.getBeforeOrNextHour(2), "productEndTime", YMTDateUtil.getBeforeOrNextHour(3)));
		Thread.sleep(2000);
		if(effectnow){
			//修改库存时间
			new YmtProductActivityStockWapper().updateStartTimeByProductId(productId, YMTDateUtil.getBeforeOrNextSecond(-300, YMTDateUtil.YMDHMS));
			//修改活动时间
			new ActivityProductsWapper().updateStartTimeByInAid(Integer.valueOf(inaid), YMTDateUtil.getBeforeOrNextHour(new Date(),1));
		}
		updateProductTimeStamp(productId);
	}
	
	/*
	 * 用于活动结束返库存，缩短结束时间
	 * endTime_Second:传入秒
	 */
	public static void approveProductInActivityV3(String productId,String inaid,boolean effectnow,int endTime_Second) throws Exception{
		Logger.comment("审核活动商品ProductInActivityId:"+inaid);
		AdminCallService.approveProductInActivity(adminuser, adminpwd, inaid,
//				MapUtil.hashMap("productBeginTime", YMTDateUtil.getBeforeOrNextSecond(5), "productEndTime", YMTDateUtil.getBeforeOrNextSecond(10 * 60 * 60 * 24)));
				MapUtil.hashMap("productBeginTime", YMTDateUtil.getBeforeOrNextSecond(5), "productEndTime", YMTDateUtil.getBeforeOrNextSecond(6)));
		Thread.sleep(2000);
		if(effectnow){
			//修改库存时间
			new YmtProductActivityStockWapper().updateStartTimeByProductId(productId, YMTDateUtil.getBeforeOrNextSecond(-300, YMTDateUtil.YMDHMS));
			//修改活动时间
			new ActivityProductsWapper().updateStartTimeByInAid(Integer.valueOf(inaid), YMTDateUtil.getBeforeOrNextDate(-1));
		}
		//updateProductTimeStamp(productId);
	}
	/**
	 * 更新商品时间戳
	 * 用于清理缓存
	 * @param productId
	 * @throws Exception
	 */
	public static void updateProductTimeStamp(String productId) throws Exception{
		ProductTimeStampWapper ProductTimeStampWapper=new ProductTimeStampWapper();
		ProductTimeStampWapper.update(productId, MapUtil.hashMap("aut",new Date()));
		ProductTimeStampWapper.update(productId, MapUtil.hashMap("sut",new Date()));
		ProductTimeStampWapper.update(productId, MapUtil.hashMap("cut",new Date()));
		ProductTimeStampWapper.update(productId, MapUtil.hashMap("lut",new Date()));
	}
	
	/**
	 * 压测用 床stg商品
	 * 
	 * @param sellerName
	 * @param sellerId
	 * @param stockNum
	 * @return
	 * @throws Exception
	 */
	public static String getStgProductId(String sellerName, int sellerId, int stockNum,Calendar endtime) throws Exception {
		Map updateMap = new HashMap();
		for (int i = 0; i < 10; i++) {
			updateMap.put("product->catalogList[" + i + "]->stock", stockNum);
			updateMap.put("product->catalogList[" + i + "]->action", 0);
			updateMap.put("product->catalogList[" + i + "]->operateType", 1);
			updateMap.put("product->catalogList[" + i + "]->price", price);
			updateMap.put("product->catalogList[" + i + "]->vipPrice", price);
			updateMap.put("product->catalogList[" + i + "]->newPrice", price);
			updateMap.put("product->catalogList[" + i + "]->propertyList[0]->propertyValue", i);
		}
		updateMap.put("product->catalogStatus", 10);
		updateMap.put("sellerName", sellerName);
		updateMap.put("sellerId", sellerId);
		
		updateMap.put("product->productName", "测试商品A");
		updateMap.put("product->brandId", ProductManagerCallServiceV3.BrandId);
		updateMap.put("product->onSaleType", 1);
		// 设为为过去5天前发布的商品
		Calendar c = Calendar.getInstance();
		c.add(Calendar.DAY_OF_MONTH, -1);
		updateMap.put("product->validStart", sdf.format(c.getTime()));

		c.add(Calendar.DAY_OF_MONTH, 25);
		updateMap.put("product->validEnd", sdf.format(c.getTime()));
		if(endtime!=null) {
			updateMap.put("product->validEnd", sdf.format(endtime.getTime()));
			updateMap.put("product->autoRefresh", false);
		}
		String proId = "";
		String fullPath = "com.ymatou.iapi.productmanager/AddSellerProductCall/addstgproduct.json";
		JSONObject addProductBean = JsonBeanHelper.getJsonBean(fullPath);
		JsonBeanHelper.updateJsonBean(addProductBean, updateMap);
		try{
			proId = ProductManagerCallServiceV2.addNewProduct(addProductBean).getJSONObject("Data").getString("ProductId");
		}catch (Exception e) {
			proId = ProductManagerCallServiceV2.addNewProduct(addProductBean).getJSONObject("Data").getString("ProductId");
		}
		return proId;

	}

	/**
	 * 压测用 获取一个stg商品
	 * 
	 * @param sellerName
	 * @param sellerId
	 * @param stockNum
	 * @return
	 * @throws Exception
	 */
	public static String getStgOneProductId(String sellerName, int sellerId, int stockNum) throws Exception {
		Map updateMap = new HashMap();
		for (int i = 0; i < 1; i++) {
			updateMap.put("product->catalogList[" + i + "]->stock", stockNum);
			updateMap.put("product->catalogList[" + i + "]->action", 0);
			updateMap.put("product->catalogList[" + i + "]->operateType", 1);
			updateMap.put("product->catalogList[" + i + "]->price", price);
			updateMap.put("product->catalogList[" + i + "]->vipPrice", price);
			updateMap.put("product->catalogList[" + i + "]->newPrice", price);
			updateMap.put("product->catalogList[" + i + "]->propertyList[0]->propertyValue", i);
			//预售商品
//			updateMap.put("product->catalogList[" + i + "]->isPreSale", true);
		}
		//时效
		updateMap.put("product->deliveryAging",15);
		//2=三方
		updateMap.put("product->deliveryCompanyType", 2);
		//catalogStatus7 7拼邮
		//3383 用5
		//10=境外
		updateMap.put("product->catalogStatus", 10);
		updateMap.put("sellerName", sellerName);
		updateMap.put("sellerId", sellerId);
		updateMap.put("product->brandId", ProductManagerCallServiceV3.BrandId);
		updateMap.put("product->onSaleType", 1);
		// 设为为过去5天前发布的商品
		Calendar c = Calendar.getInstance();
		c.add(Calendar.DAY_OF_MONTH, 0);
		updateMap.put("product->validStart", sdf.format(c.getTime()));

		c.add(Calendar.DAY_OF_MONTH, 3);
		updateMap.put("product->validEnd", sdf.format(c.getTime()));
		String proId = "";
		String fullPath = "com.ymatou.iapi.productmanager/AddSellerProductCall/addstgoneproduct.json";
		JSONObject addProductBean = JsonBeanHelper.getJsonBean(fullPath);
		JsonBeanHelper.updateJsonBean(addProductBean, updateMap);
		//出现异常重新创建一次商品
		try{
			proId = ProductManagerCallServiceV2.addNewProduct(addProductBean).getJSONObject("Data").getString("ProductId");
		}catch (Exception e) {
			proId = ProductManagerCallServiceV2.addNewProduct(addProductBean).getJSONObject("Data").getString("ProductId");
		}
		return proId;

	}

	/**
	 * 创建一个组合商品packageId
	 * 
	 * @param SubCatalogName
	 * @return packageId
	 * @throws JSONException
	 */
	public static Integer saveCatalogPackage(String SubCatalogName) throws JSONException {
		SaveCatalogPackageListCall saveCatalogPackageListCall = new SaveCatalogPackageListCall();
		Integer packageId1 = saveCatalogPackageListCall.callAndGetReturnData(MapUtil.hashMap("ProductPackageList[0]->SubCatalogName", SubCatalogName)).getJSONObject("Data")
				.getJSONArray("SubCatalogIdList").getInt(0);
		return packageId1;
	}

	/**
	 * 用于设置规格id失效
	 * 
	 * @param CatalogIds
	 *            规格id
	 * @param iaction
	 *            -1 失效
	 * @throws InterruptedException
	 */
	public static void updateCatalogIdiAction(List<String> CatalogIds, Integer iaction) throws InterruptedException {
		YmtCatalogsIWapper CIWapper = new YmtCatalogsIWapper();
		for (String CatalogId : CatalogIds) {
			CIWapper.updateiActionByCatalogId(iaction, CatalogId);
		}
	}

	/**
	 * 使用productId+AddSellerProductRequest 初始化 ModifySellerProductRequest
	 * 
	 * @param productId
	 * @param addBean
	 * @return
	 */
	public static ModifySellerProductRequest getModifySellerProductRequestFromAddProductBean(String productId, AddSellerProductRequest addBean) {
		IntergratedProductMapper ipm = SqlMapperFactory.getIntergratedProductMapper();

		ModifySellerProductRequest modifyBean = new ModifySellerProductRequest();
		//modifyBean.setFirstRelease(addBean.isFirstRelease());
		modifyBean.setProduct(addBean.getProduct());
		modifyBean.setSellerId(addBean.getSellerId());
		modifyBean.setProductId(productId);
		modifyBean.setProductSite(addBean.getProductSite());
		modifyBean.setSellerName(addBean.getSellerName());
		modifyBean.getProduct().setProductId(productId);
		modifyBean.getProduct().setReleaseProduct(false);

		List<CatalogSaveModel> catalogListReq = modifyBean.getProduct().getCatalogList();
		List<CatalogSaveModel> catalogSaveModelInSql = new ArrayList<>();

		List<Map<String, Object>> catalogsInSqlMap = ipm.selectCatalogsByProdId(productId);
		for (Map<String, Object> catalogMap : catalogsInSqlMap) {
			CatalogSaveModel catalogSaveModel = new CatalogSaveModel();
			catalogSaveModel.setCatalogId(catalogMap.get("sCatalogId").toString());

			// 属性
			List<CatalogPropertySaveModel> propertyList = new ArrayList<>();
			List<Map<String, Object>> proAndValMapList = ipm.selectCatalogProAndValByCatalogId(catalogMap.get("sCatalogId").toString());

			for (Map<String, Object> proAndValMap : proAndValMapList) {
				CatalogPropertySaveModel catalogPropertySaveModel = new CatalogPropertySaveModel();
				catalogPropertySaveModel.setPropertyName(proAndValMap.get("sProductProperty").toString());
				catalogPropertySaveModel.setPropertyValue(proAndValMap.get("sCategoryAttribute").toString());
				catalogPropertySaveModel.setPropertyUrl((proAndValMap.get("sPicUrl") == null) ? null : proAndValMap.get("sPicUrl").toString());
				propertyList.add(catalogPropertySaveModel);
			}

			catalogSaveModel.setPropertyList(propertyList);
			catalogSaveModelInSql.add(catalogSaveModel);
		}

		// 找到对应匹配请求的规格 设置catalog值
		List<String> catalogIds = catalogsInSqlMap.stream().map(x -> x.get("sCatalogId").toString()).collect(Collectors.toList());

		if (catalogListReq.size() == 1) {
			// 单规格
			catalogListReq.get(0).setCatalogId(catalogIds.get(0));
		} else {
			// 多规格
			for (CatalogSaveModel catalogSaveModelReq : catalogListReq) {
				if (catalogSaveModelReq.getPropertyList().size() == 1) {
					// 单属性
					String property = catalogSaveModelReq.getPropertyList().get(0).getPropertyValue();
					CatalogSaveModel sqlCatalog = catalogSaveModelInSql.stream().filter(x -> x.getPropertyList().get(0).getPropertyValue().equals(property)).findFirst()
							.orElse(null);
					// Logger.verifyIsNull(sqlCatalog,
					// "该属性应该存在规格:["+property+"]");
					catalogSaveModelReq.setCatalogId(sqlCatalog.getCatalogId());

				} else {
					// 双属性
					String property1 = catalogSaveModelReq.getPropertyList().get(0).getPropertyValue();
					String property2 = catalogSaveModelReq.getPropertyList().get(1).getPropertyValue();
					CatalogSaveModel sqlCatalog = catalogSaveModelInSql.stream()
							.filter(x -> (x.getPropertyList().get(0).getPropertyValue().equals(property1) && x.getPropertyList().get(1).getPropertyValue().equals(property2))
									|| (x.getPropertyList().get(1).getPropertyValue().equals(property1) && x.getPropertyList().get(0).getPropertyValue().equals(property2)))
							.findFirst().orElse(null);

					// Logger.verifyNotNull(sqlCatalog,
					// "该属性应该存在规格:["+property1+","+property2+"]");
					catalogSaveModelReq.setCatalogId(sqlCatalog.getCatalogId());
					catalogSaveModelReq.setOperateType(2);
				}
			}
		}

		return modifyBean;
	}

	// limitType 0:活动限购, 1:活动商品限购
	public static void updateActivityLimit(int activityId, int limitType, int limitNum) throws Exception {
		// update sql
		YmtActivityWapper ymtActivityWapper = new YmtActivityWapper();
		int sqlRet = ymtActivityWapper.updateActivityLimit(activityId, limitType, limitNum);
		String ret = sqlRet > 0 ? "成功" : "失败";
		Logger.comment("sql activityId:" + activityId + ", 限购数据修改," + ret);

		// update mongo
		if (YmtMongoDriverFactroy.isNewJavaMgoCheck()) {
			ActivityProductsWapper activityProductsWapper = new ActivityProductsWapper();
			if (limitType == 0) {
				String retMgo = activityProductsWapper.update(MapUtil.hashMap("aid", activityId), MapUtil.hashMap("alimit", limitNum)) ? "成功" : "失败";
				Logger.comment("Mongo activityId:" + activityId + ", 限购数据修改," + retMgo);
			} else {
				String retMgo = activityProductsWapper.update(MapUtil.hashMap("aid", activityId), MapUtil.hashMap("plimit", limitNum)) ? "成功" : "失败";
				Logger.comment("Mongo activityId:" + activityId + ", 限购数据修改," + retMgo);
			}

		}
	}
	
	public static List<String> getListProductId(Integer sellerId,Integer activityId,Integer count) throws Exception{
		AddSellerProductRequest addProdReq = initAddSellerProductRequest(sellerId);
		List<String> list = new ArrayList<String>();
		for(int i = 0;i<count;i++){
			String productId = addNewProductOnSale(addProdReq).get("Data").getAsJsonObject().get("ProductId").getAsString();
			AddProductInLivesBean addProductInLivesBean = new AddProductInLivesBean();
			addProductInLivesBean.setActivityId(activityId);
			addProductInLivesBean.setProductIds(Arrays.asList(productId));
			addProductInLivesBean.setUserId(sellerId);
			AddProductInLivesCall addProductInLivesCall = new AddProductInLivesCall();
			addProductInLivesCall.setData(addProductInLivesBean);
			addProductInLivesCall.callService();
			list.add(productId);
		}
		return list;
	}

	/**
	 * 获取productid
	 * @param catalogId
	 * @return
	 * @throws InterruptedException 
	 */
	public static String getProductId(String catalogId) throws InterruptedException{
		 return new YmtCatalogsIWapper().selectCatalogsByCatalogId(catalogId).getsProductId();
	}

	/**
	 * 获取一个安利会商品
	 * @return
	 * @throws Exception
	 */
	public static String getalhProductId() throws Exception{
		int sellerId = Integer.parseInt(EnvSetup.getData("productsellerid"));
		AddSellerProductRequest addProdReq = ProductManagerCallServiceV3.initAddSellerProductRequest(sellerId);
//		String productId = ProductManagerCallServiceV2.addNewProduct(addProdReq).get("Data").getAsJsonObject()
//				.get("ProductId").getAsString();
		//update by wuwen 20201228 mockAddProduct
		String productId = ProductManagerCallServiceV3.AddSellerProduct(addProdReq);
		List<String> list = new ArrayList<String>();
		list.add(productId);
		BatchAddAlhProductBean batchaddalhproductBean = new BatchAddAlhProductBean();
		BatchAddAlhProductCall batchaddalhproductCall = new BatchAddAlhProductCall();
		batchaddalhproductBean.setUserId(sellerId);
		batchaddalhproductBean.setProductIds(list);
		batchaddalhproductCall.setData(batchaddalhproductBean);
		batchaddalhproductCall.callService();
		Logger.verifyEquals("200", batchaddalhproductCall.getJsonObject().get("Code").getAsString(), "判断code");
	
		return productId;
	}
	/**
	 * 添加商品成为安利会商品
	 * @param sellerId
	 * @param productId
	 * @throws Exception
	 */
	public static void addAlhProduct(Integer sellerId,String productId) throws Exception{
		AddSellerProductRequest addProdReq = ProductManagerCallServiceV3.initAddSellerProductRequest(sellerId);
		List<String> list = new ArrayList<String>();
		list.add(productId);
		BatchAddAlhProductBean batchaddalhproductBean = new BatchAddAlhProductBean();
		BatchAddAlhProductCall batchaddalhproductCall = new BatchAddAlhProductCall();
		batchaddalhproductBean.setUserId(sellerId);
		batchaddalhproductBean.setProductIds(list);
		batchaddalhproductCall.setData(batchaddalhproductBean);
		batchaddalhproductCall.callService();
	}
	
	
	/**
	 * 增加秒杀商品
	 * @throws Exception
	 */
	public static int addSecKillStock(int activityid,String productId,int userId,boolean action) throws Exception{
		YmtSecKillStockConfigWapper wapper=new YmtSecKillStockConfigWapper();
		YmtSecKillStockConfig bean=new YmtSecKillStockConfig();
		bean.setAction(action);
		bean.setActivityId(activityid);
		bean.setProductId(productId);
		bean.setUserId(userId);
		return wapper.insertSecKillStockConfig(bean);
	}
	public static void main(String args[]) throws Exception {
//		ArrayList<String> list = TestDataManager.getLines("stgcreateproduct10.log");
//		for (String info : list) {
//			String[] ss = info.split(":");
//			String seller = ss[0];
//			String pid = ss[2];
//			String cid = ss[4];
//			System.out.println(seller + "," + pid + "," + cid);
//			ProductManagerCallServiceV2.batchSetProductOnSale(Arrays.asList(pid), Integer.valueOf(seller));
//		}
//24635724
		ProductManagerCallServiceV2.offSaleAllProduct(24635724,true);

	}
	
	
}
